Fit Lightbox container in window if image is larger

Posted by Bobe on Stack Overflow See other posts from Stack Overflow or by Bobe
Published on 2012-08-30T09:33:58Z Indexed on 2012/08/30 9:38 UTC
Read the original article Hit count: 483

I'm just looking for a simple way to set the max width and height of the Lightbox container and image based on the window size if the image is larger than the current window size.

So say the image is 2000x1200 and the window is 1280x1024, then the max-height and max-width of div.lb-outerContainer and img.lb-image should be set to

$(window).height() - 286, $(window).width() - 60 

and

$(window).height() - 306, $(window).width() - 80

respectively.

I'm just having a bit of trouble determining where to go about implementing these rules. Do I do it in the lightbox.js file? If so, where? Would it be acceptable to just throw in some script on the page it's used on?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about size