Lightbox JS v2.0

by Lokesh Dhakar

Example

How to Use:

Part 1 - Setup

  1. Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header.
2.           <script type="text/javascript" src="js/prototype.js"></script>
3.           <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
4.           <script type="text/javascript" src="js/lightbox_s.js"></script>
5.           <script type="text/javascript" src="js/swfobject.js"></script>
  1. Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
7.           <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
  1. Check the CSS and make sure the referenced prevlabel.gif and nextlabel.gif files are in the right location. Also, make sure the loading.gif and close1.gif files as referenced near the top of the lightbox_s.js file are in the right location.

Part 2 - Activate

  1. Add a rel="lightbox" attribute to any link tag to activate the lightbox. For example:
2.           <a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

Optional: Use the title attribute if you want to show a caption.

  1. If you have a set of related images that you would like to show as slideshow, follow step one but additionally include a group name between square brackets in the rel attribute. For example:
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
If you want to show just the link to the first image of your slideshow, you can do it like that:
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">slideshow</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]"></a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]"></a>
 
There is additional attributes available for the first image in slideshow: 
startslideshow="false" – by default lightbox starts slideshow. Set it to false if you want to override this behavior.
forever="true" – by default slideshow runs only once. Set it to true if you want to override this behavior.
slideDuration="5" – the default slide duration is 3 sec. Set it to any number if you want to override it for particalar slideshow.
music="song.mp3” – URL to mp3 file for slideshow music
<a href="images/image-1.jpg" startslideshow=”true” forever=”false” slideDuration=”5” rel="lightbox[bday]">slideshow</a>

No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!