Crunch Mode Blog - A State of Mind by Developers at D2Soft Technologies

Like us on Facebook

Error message when using jQuery lightbox with dynamic images

I was trying to use the jQuery lightbox plugin in a test site written in ASP.NET.  I could display the images in the page, but when trying to open one image using lightbox, I had this error message:

You have to specify the size.  Add ?lightbox[width]=600&lightbox[height]=400 at the end of the url.

I first thought I was missing some JavaScript code or reference.  But I finally found the issue.  I was using an ASP.NET page to generate and return an image dynamically.  So instead of pointing to a static image (like image.jpg) in my HTML code for the lightbox plugin, I was pointing to the ASP.NET page (like /mySite/dynImage.aspx).  For some reason, this works for the thumbnail image, but it doesn't for lightbox.

To solve the issue, I added "format=.jpg" at the end of my URL for the image, like "/mySite/dynImage.aspx?format=.jpg".  I didn't try to investigate more as this quick fix made lightbox accept my image link.  However, I expect that lightbox is doing a string search to find the image format.  But adding ".jpg" in my URL, although not necessary for my actual ASP.NET page, it seems that lightbox is now able to solve the mystery of the link.


 


Post your Comment: