by Justin Barkhuff, justin@justinbarkhuff.com
This code is provided to you free of charge, but it does require my time and effort to maintain and to support those who use it.
You can help keep this code free and alive by making a donation:
Version 1.1, released August 15, 2007
If you are using Prototype 1.6, replace lightbox.js with the Prototype 1.6 compatible lightbox.js
All users of Version 1.0 should upgrade to this new release. See the Change Log for details.
Lightbox Slideshow is a simple, unobtrusive script used to overlay images on the current page.
It’s basically a better version of Lightbox2.
In fact, the technical requirements and installation steps are identical to Lightbox2, but with Lightbox Slideshow, the underlying code is much better and there are lots of useful configuration options.
Here are just a few things you can do with Lightbox Slideshow that you can’t do with Lightbox2:
See the configuration options section for more.
Single image
Group of Images
If you are already using Lightbox2, just replace your existing lightbox.js and lightbox.css files with the ones included in the download. Be sure the image references in the CSS file are correct.
The downloadable zip file contains all files required to run Lightbox Slideshow and the sample page and photos.
After downloading the zip file, extract all the files to any directory on your computer and upload that directory anywhere on your site.
You should then be able to view this functioning sample page at: http://yoursite.com/your_upload_directory/sample.htm
If you are using Prototype 1.6, replace lightbox.js with the Prototype 1.6 compatible lightbox.js
Lightbox Slideshow uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header (in this order).
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="lightbox.js"></script>
Include the CSS file (or append your existing stylesheet with the Lightbox Slideshow styles).
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
Check the CSS and make sure the referenced image files are in the right location.
Add a rel="lightbox" attribute to any link tag to activate the lightbox. For example:
<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.
If you have a set of related images that you would like to group, 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>
There are no limits to the number of image sets per page or how many images are allowed in each set. Go nuts!
Lightbox Slideshow allows you to easily configure a number of options. Configuration options are specified by passing an object of your configurations to the Lightbox.initialize() method. This involves editing the last line of the lightbox.js file.
Here are the configuration options:
Do you use Google Analytics? Here is a sample configuration that enables tracking of individual image views. This line of code would replace the last line of your lightbox.js file:
Event.observe(window,'load',function(){ Lightbox.initialize({googleAnalytics:true}); });
Here is a sample configuration that shows the group name for groups of images and disables the autoPlay slideshow setting. Remember, this line of code would replace the last line of your lightbox.js file.
Event.observe(window,'load',function(){ Lightbox.initialize({showGroupName:true,autoPlay:false}); });
Is your site in German? Here is a sample configuration that uses German-specific strings. These lines of code would replace the last line of your lightbox.js file:
var lbStringsDE = {
closeLink : 'ende',
loadingMsg : 'laden',
nextLink : 'weiter »',
prevLink : '« zurück',
startSlideshow : 'start diashow',
stopSlideshow : 'stopp diashow',
numDisplayPrefix : 'Bild',
numDisplaySeparator : 'von'
};
Event.observe(window,'load',function(){ Lightbox.initialize({strings:lbStringsDE}); });