2011
Change Lightbox 0.5 Image Size
Fatal Error:get('adsPerSlot') in Admin Options don't exist (not an array)!Your ads will be inserted here by
Easy Ads Lite.
Please go to the plugin admin page to paste your ad code.
Update 2011: For those people who had problems with the below instructions.. please find in on my website here. And when you’re there take a look at my site and see what you think about it
Lightbox 2 has the functionality to set maximum width and height. But what about previous versions? To set the maximum image width and height for lightbox (version 0.5) you need to do some extra coding yourself. Open the jquery.lightbox-0.5.js file and search for the next pieces of code (in bold below):
settings = jQuery.extend({
maxWidth: null,
maxHeight: null,
...
Then search for the next function (in bold) and write copy and paste the code underneath it:
Your ads will be inserted here by
Easy Ads Lite.
Please go to the plugin admin page to paste your ad code.
function _resize_container_image_box(intImageWidth,intImageHeight) {
//rescale if necessary
if((settings.maxWidth != null && settings.maxHeight != null) && (intImageWidth > settings.maxWidth || intImageHeight > settings.maxHeight)){
var isWider = intImageWidth > intImageHeight;//is the image wide or tall?
var scale = isWider ? settings.maxWidth/intImageWidth : settings.maxHeight/intImageHeight;
intImageWidth = intImageWidth * scale;
intImageHeight = intImageHeight * scale;
}
$('#lightbox-image').height(intImageHeight);
$('#lightbox-image').width(intImageWidth);
...
With the above code added, now you can specify the maximum image size when calling a new lightbox instance with the next code:
$('.yourClass a').lightBox({
maxHeight: 500,
maxWidth: 700
});
You can also set the maximum width and height according to the user’s screen width and height by using the following code:
$('.yourClass a').lightBox({
maxHeight: screen.height * 0.9,
maxWidth: screen.width * 0.9
});
Resources: here
Your ads will be inserted here by
Easy Ads Lite.
Please go to the plugin admin page to paste your ad code.
10 Comments
Leave a comment
Recent Posts
Favourite Links
Tags
Archives
- May 2012
- February 2012
- December 2011
- October 2011
- September 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- June 2010
- May 2010
- April 2010
- March 2010
- July 2009
- June 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- September 2008
- August 2008
- June 2008
- May 2008
- March 2008
- February 2008
- November 2007
- September 2007
- July 2007
- June 2007
- May 2007
- February 2007
- January 2007
- November 2006
- October 2006
Categories
- Android
- Apple
- ASP.Net
- Blackberry OS
- CMS
- Creative Computing
- Crystal Reports
- Day to Day
- Deep Design Malta
- Design and Development
- Development Tools
- Games
- Google Analytics
- Google Gmail
- Internet Explorer
- iPhone/3G
- iPod Touch
- JavaScript
- JQuery
- Microsoft
- Microsoft SQL Server
- Microsoft Visual Studio
- MS Office
- My Blog
- NetBeans
- Off Topic
- Online Services
- Permissions
- Phones and Tablets Platforms
- Project NINE
- PSP NGP
- Quickie
- SEO
- Silverlight For WP7
- Sitefinity
- Sony
- Uncategorized
- Utilities
- VB .Net
- Windows 7
- Windows 8
- Windows Live
- Windows Mobile
- Windows Phone 7
- Windows Vista
- Wordpress
- WP Apps
- Yellow Pages





It doesn’t work…
Hmm.. it should work. I tested it myself and worked fine for me. What Lightbox version are you using? This only works on Lightbox version 0.5.
I tried it as well (with jQuery Lightbox 0.5) and the lightbox stopped working.
If you’re still having this problem.. Try the code as I did it from the link above and see if it works for you.
Because I just give the code:
if(intImageHeight > screen.height)
{
WysDzielnik = screen.height/intImageHeight;
intImageHeight = screen.height;
intImageWidth = intImageWidth * WysDzielnik;
}
if(intImageWidth > screen.width)
{
SzerDzielnik = screen.width/intImageWidth;
intImageWidth = screen.width;
intImageHeight = intImageHeight * SzerDzielnik * 0,8;
}
Sorry, no last entry:
if (intImageHeight> screen.height)
{
WysDzielnik = screen.height / intImageHeight;
intImageHeight = screen.height;
intImageWidth = intImageWidth * WysDzielnik;
}
if (intImageWidth> screen.width)
{
SzerDzielnik = screen.width / intImageWidth;
intImageWidth = screen.width;
intImageHeight = intImageHeight * SzerDzielnik;
}
Try the code as I did it from the link above and see if it works for you.
Great fix!
Works perfectly. Thanks a lot.
I set $(‘.gallery a’).lightBox({ maxHeight: 20, maxWidth: 20});
but its not working its still showing the original size
please help me
Hi,
I tried youur solution but it doesn’t work for me.
i did it but i use practicaly the css:
in the function ‘_resize_container_image_box’ i add the code you gave to us:
“page_width=window.innerWidth;
page_height=window.innerHeight;
if((page_width != null && page_height != null) && (intImageWidth > page_width || intImageHeight > page_height)){
var isWider = intImageWidth > intImageHeight;//is the image wide or tall?
var scale = isWider ? page_width/intImageWidth : page_height/intImageHeight;
intImageWidth = intImageWidth * scale;
intImageHeight = intImageHeight * scale;
}
”
and at the end of the function i add other thing:
”
$(‘#lightbox-container-image-box’).css({ ‘max-width’: intWidth, ‘max-height’:intHeight });
$(‘#lightbox-container-image-box img’).css({ ‘max-width’: intImageWidth, ‘max-height’:intImageHeight });
“