views:

290

answers:

3

Does anybody know how to force resize the image that opens in lightbox either in CSS or by hacking lightbox?

I know it's not a good solution to having a fixed image size (should be done on upload) but it is a specific requirement of a client.

Thanks.

A: 

It's not a bad solution having fixed size. Just set max-height or max-width (in CSS) to whatever (but not both)- The image will then scale correctly.

But all images must be same format, otherwise height / width may vary.

And if you set fixed size in CSS (width, height), then the images will be scewed.

Steven
Hi, Thanks for your response. I did have a try playing with the css, the problem I had was that some widths are set inline. Also the fact that it's not just the image size that needs setting, its all the containers too.
Probocop
In the end I set a max-width and max-height in CSS which solved the problem, Thanks.
Probocop
A: 

Rather than using css, just resize the image using jquery's width() and height() methods on the image element.

Before you do that I'd recommend dividing one by the other to get the ratio, so you don't distort the image! :)

Alex
A: 

In your CSS you can have the image size adjust to fill the maximum width while still maintaining the same aspect ratio like this:

img {width:100%; height:auto}

As long as the container is a block this should adjust the image size. Be aware it'll probably just look back because the image scaler in most browsers use "nearest neighbor" sampling scale the images

Joseph Silvashy