Features
From a functional point of view, Slimbox 2 has the following added features compared to the original Lightbox:
- Slimbox is ready to launch as soon as the document is ready. This means that you don't have to wait for all images of the page to be loaded before clicking on a link that will launch the Lightbox effect.
- Slimbox also centers images vertically on startup, not just horizontally. Vertical scrolling is still possible.
- It works perfectly on horizontal-scrolling websites.
- It temporary hides flash animations and other embedded videos while it is open to avoid display bugs in some browsers. It also hides select boxes in Internet Explorer 6.
- Using a special option ("loop"), it allows you to navigate between the first and last images.
- Slimbox is more responsive; it allows you to close it immediately at any time using the keyboard or mouse and to instantly navigate to any image before the current image has loaded or the animations are complete.
- The script is more robust; for example you can try to start and stop Slimbox or navigate between images very quickly to interrupt the animations and resume them and you won't notice any bug like in the original Lightbox where sometimes the animation stops or the elements are wrongly sized or positioned.
- Slimbox can be launched from the traditional image links inside the page like the original Lightbox, but also directly from Javascript using its complete API.
From a design point of view, Slimbox 2 is very different from Lightbox:
- The code is optimized to an insane level and has been written from scratch with efficiency in mind for the jQuery library instead of the huge Prototype/Scriptaculous. The script itself is as tiny as 4kb (minified, uncompressed).
- Slimbox can be entirely customized thanks to many options. You can change the duration of any effect, the counter text translation or even the navigtation keys.
- Slimbox has a much more powerful API, allowing you to apply the Lightbox effect easily on any clickable element or from any script. For example, it can be easily integrated with links pointing to Flickr or Picasa Web Albums pages or with any javascript image gallery.
- The Slimbox CSS(Cascading Style Sheets) are simpler and 100% valid (no more CSS hacks). Also, every visual aspect of Slimbox (including images) is specified in the CSS instead of the Javascript so it is easier to style. You may even change any border size in the CSS and Slimbox will still work fine, which means that nothing is "hard-coded" in the source code.
Slimbox 2 is currently the smallest Lightbox-like script available for the jQuery library.
Compatibility
Slimbox 2 is compatible with all modern browsers: Firefox 2+, Internet Explorer 6+, Opera 9+ and Opera for Wii, Safari 3+, Camino and Google Chrome.
It works with both strict mode and quirks mode web pages.
Unlike many Lightbox-like scripts, it displays fine in case of horizontal scrolling of the web page.
It is disabled by default on mobile devices (Android, iPhone/iPod, Symbian, Windows Mobile, BlackBerry).
Note: there is a bug in Google Chrome versions 4 to 8 for Linux with many non-english locales, causing the overlay to stay invisible when Slimbox is opened. This bug does not affect other operating systems and was fixed since Chrome 9.
Requirements
Slimbox 2.04 requires the jQuery library, version 1.3 or more recent. If you don't already have it, you can download jQuery from its official website.
Usage
Usage is exactly the same as for Lightbox by default, but Slimbox 2 offers more options.
Because it was designed to be 100% compatible with Lightbox, you just need to replace the scripts combination "Prototype + Scriptaculous + Lightbox" with "jQuery + Slimbox 2" in the header of your pages and your Lightbox effects will work just as well as before. Well, a little better.
Setup
1. Include the script in the header of your page, after the inclusion of the mootools framework:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/slimbox2.js"></script>
There are some options that you can specify in the form of a javascript object inside the script (look for "put custom options here"). The default values should be just fine, however if you want you can change the following:
- loop: Boolean; if set to true, allows the user to navigate between the first and last images of a Slimbox gallery, when there is more than one image to display. Default is false.
- overlayOpacity: The level of opacity of the background overlay. 1 Is opaque, 0 is completely transparent. You can change the color in the CSS file. Default is 0.8.
- overlayFadeDuration: The duration of the overlay fade-in and fade-out animations, in milliseconds. Set it to 1 to disable the overlay fade effects. Default is 400.
- resizeDuration: The duration of the resize animation for width and height, in milliseconds. Set it to 1 to disable resize animations. Default is 400.
- resizeEasing: The name of the easing effect that you want to use for the resize animation (jQuery Easing Plugin required). Many easings require a longer execution time to look good, so you should adjust the resizeDuration option above as well. Default is jQuery's built-in default easing, "swing".
- initialWidth: The initial width of the box, in pixels. Default is 250.
- initialHeight: The initial height of the box, in pixels. Default is 250.
- imageFadeDuration: The duration of the image fade-in animation, in milliseconds. Set it to 1 to disable this effect and make the image appear instantly. Default is 400.
- captionAnimationDuration: The duration of the caption animation, in milliseconds. Set it to 1 to disable it and make the caption appear instantly. Default is 400.
- counterText: Text value; allows you to customize, translate or disable the counter text which appears in the captions when multiple images are shown. Inside the text, {x} will be replaced by the current image index, and {y} will be replaced by the total number of images. Set it to false (boolean value, without quotes) or "" to disable the counter display. Default is "Image {x} of {y}".
- closeKeys: An array of key codes of the keys to press to close Slimbox. Default is [27, 88, 67] which means Esc (27), "x" (88) and "c" (67).
- previousKeys: An array of key codes of the keys to press to navigate to the previous image. Default is [37, 80] which means Left arrow (37) and "p" (80).
- nextKeys: An array of key codes of the keys to press to navigate to the next image. Default is [39, 78] which means Right arrow (39) and "n" (78).
Example of a custom options object, including french translation:
{
overlayOpacity: 0.6,
resizeEasing: "easeOutElastic",
captionAnimationDuration: 1,
counterText: "Image {x} sur {y}",
closeKeys: [27, 70],
nextKeys: [39, 83]
}2. Include the CSS file in the header of your page, or add it to an existing CSS style sheet:
<link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" />
Or, if you are using a right-to-left language:
<link rel="stylesheet" href="css/slimbox2-rtl.css" type="text/css" media="screen" />
If you keep the provided CSS as is, you must place the 4 required images in the same folder as the CSS file. Of course you can change the images or move them to another place, then you just need to edit the CSS URLs (and the image width and height for the "Close" image) to reflect your changes. You don't even need to edit the javascript.
You can also change the fonts for the caption and the image counter, the width of the border around the lightbox and the caption, the margins in the caption and every color. You must not add new CSS rules.
Activate
Add the rel="lightbox" attribute to the links pointing to your full-sized images. Use the optional title attribute if you want to show a caption:
<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
You can even use HTML in the caption if you want. You must replace the < and > characters with HTML entities and use single quotes instead of double quotes.
For sets of related images that you want to group and make navigable, add a group name to the rel attribute just after the "lightbox" word, for example:
<a href="images/image-1.jpg" rel="lightbox-cats">image #1</a>
<a href="images/image-2.jpg" rel="lightbox-cats">image #2</a>
<a href="images/image-3.jpg" rel="lightbox-cats">image #3</a>
I don't recommend using square brackets "[ ]" around group names in the rel attribute like the original Lightbox script does because these characters are invalid for XHTML and XML attributes, meaning that your web page would not validate against the latest standards.
hi christophe
i would like to thanks you for a great script. it is very robust and easy to install and play with. i managed to include and compress your files in my js.php and css.php files without difficulty and get load times way down.
Hi!! I tried to set up the Flickr, and I can't make it works into separate image sets. Is there anyway I can do it?
Hi, I want to thank you for this script too. It works perfect to me. Is there a way to open one image from an iframe in the whole parent page? I mean the thumbnail is inside the iframe and I want the image and the overlay be applied on the whole parent page of the iframe. Currently the image and the overlay is applied to the iframe only. Thanks
Hi...I love this script but I am having a LOT of trouble changing the image of the preloader to fit the black background I have changed the slimbox to...I have created a new images...but it doesn't change the image !!! thanks
how can i change the color of the text and links in the pop up window using css?
How do I load a html page into slimbox 2?
I need to add links inside the caption area, how can this be done?
Half of my image in the light box is missing unless I mouse over it, any idea why?
How to add some description to the box?
Any way to always display the "Next" and "Previous" images?
thanks for slimebox! great code!
--
question: how does slimebox decide on the order of links to display in a gallery:
problem: sb2 is opening the last image "GLU3" and not the "GLU1"? why is the button "prev" on the last picture (makes sense)c on the right hand side, insteadt of "left-hand" side? how can i tell sb2 to open FIRST "GLU1" and not "GLU3" ?!
thank you very much
Is there an easy way to limit the maximum width/height of the opened slimbox? I have some images which are really too big and don't want to resize everything that is being uploaded...
Is there an easy way to limit the maximum width/height of the opened slimbox? I have some images which are really too big and don't want to resize everything that is being uploaded...
ME TOOOOOOO
I'm having the same problem as Daniel Ko... (the comment from Jul 13, 2010)
What should be the last image, Slimbox is displaying first. So in an image gallery of say, 10 images, the first image to display is the tenth, and says "Image 10 of 10". How do I fix this?
Can you make the lightboxed image on, by default, so the user sees it and then clicks close to view the page?
Does anybody know how to use slimbox full-screen? Like shadowbox
how can i prevent the slimbox from showing when i drag the images..?
i also implement ah sortable feature but when i drag the image it opens the slimbox
Hello,
I use blogger. Is there anyway I could point this script in my head tag? Using it as:
does not work. Any help? Thank you :)
Hi great plugin, but how do you move the bottom container (contining the text description or caption for the image) to the left of the container with the image in it?
thanks in advance
How do I get the following code to work?
For anyone who wants to set the slimbox2 to start from a the beginning or a specific position: I was searching high and low for the imageStart function for the slimbox2 but no dice. I started logging every variable and found that S was holding the position: so i changed N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R; to N.unbind("click").click(function(){var S=N0?,U=0,T,Q=0,R;
and now my slimbox2 gallery always starts from the beginning. ...sorry for the overuse of slimbox and begining, just want it to get indexed so that other users find it fast :) Cheers ! PS: Great plugin btw. Congrats to the dev !
The next and the prev buttons are inverse, it's why you think it doesn't show the image in the right order. To put them the right way you need to go in the CSS and change #lbPrevLink for #lbNextLink, #lbPrevLink:hover for #lbNextLink:hover and #lbNextLink for #lbPrevLink and #lbNextLink:hover for #lbPrevLink:hover.