LIGHTBOX v2.04 | SHOWCASE YOUR IMAGES

Advertisement

Overview


Lightbox is a simple, unobtrusive script used to overlay images on the current page. It's a snap to setup and works on all modern browsers.

What's New in Version 2


  • Image Sets: group related images and navigate through them with ease
  • Visual Effects: Fancy Pants Transitions
  • Backwards Compatibility: YES!


Example

Single Images




Image Set


Plants: image 1 0f 4 thumbPlants: image 2 0f 4 thumbPlants: image 3 0f 4 thumb Plants: image 4 0f 4 thumb

How to Use

Part 1 - Setup


  • Lightbox 2 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="js/prototype.js"></script><script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script><script type="text/javascript" src="js/lightbox.js"></script>

  • Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
    <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

  • Check the CSS and make sure the referenced prev.gif, next.gif,loading.gif and close.gif files as referenced near the top of the lightbox.js file are in the right location.


Part 2 - Activate


  • 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, 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>

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


Download

Download Lightbox V2.04Download lightbox204.zip - All the the important stuff [.js file, css, images ]


Support

  • It doesn't work at all. The image opens up in a new page. What's wrong?
    This is commonly caused by a conflict between scripts. Check your body tag and look for an onload attribute. Example:
    <body onload="MM_preloadImages(‘/images/menu_on.gif’)…;">

    A quick fix to this problem is to append the initLightbox() to the onload attribute as so:
    <body onload="MM_preloadImages(‘/images/menu_on.gif’)…;initLightbox()">

  • It doesn't work if I click an image link before the page has finished loading.
    The script is activated only after the page has finished loading.

  • The shadow overlay doesn't stretch to cover full browser window.
    Remove the default margin and padding from the body tag. Add body{margin:0; padding: 0;} to your stylesheet.

  • Can I insert links in the caption?
    Yes, but you need to convert quotes and greater and less than symbols into their html entity equivalents. For example:
    <a href="images/image-4.jpg" rel="lightbox" title="<a href="link.html">my link</a>">Image</a>

  • Can I display flash, video, or other content using the script?
    Sorry, photos only. For other content, google for Lightbox modifications or try an alternative script such as Cody Lindley's ThickBox.

  • Can the script be called from an iframe?
    If you're using iframes, try the Lytebox modification which has better support.

  • Can I use the script in a commercial project?
    Yes. It is licensed under the Creative Commons Attribution 2.5 License.

"Thank You!!! You’ve reached the end of this post. Seeing you made it this far, we hope you enjoyed this post. If so, please consider leaving a comment or subscribing to the feed to have further articles deliverd to your feed reader. You can also follow me on Twitter."
1 Comment(s) Leave a Comment
  1. Pigeon | Friday, January 30, 2009  

    Er... I don't get it. What is this supposed to actually achieve?

    I've tried the examples above. When I click on the images there is an annoying delay while various pointless fades and animations take place, then eventually an image appears on a black background... on what appears to be a new page but isn't really, so it gives the impression that the "back" button is broken because you can't use it to return to the content that you were viewing on the "previous" page, it forces you to use the "close" box.

    Yes, *I* know it's not really a new page so you can't expect the "back" button to work, but Joe Bloggs doesn't realise that. It *looks* like a new page but it doesn't behave like one - it confuses people's expectations.

    Also the fading backgrounds and animated growing rectangles serve only to delay one's access to the bit one actually wants to see - the image itself. People want pages to load *fast* - that's why they upgrade their internet connections to higher-speed products and buy faster computers, and that's why webmasters prefer to host their sites on servers with high-bandwidth connections. Page response time is important; slow servers and slow connections are annoying enough, but things that *deliberately* slow down the loading of a page are much more annoying because it's deliberate.

    It's very easy to demonstrate the problems simply by turning off javascript and reloading this page. Without the script, the images load straightaway, without pointless delays, and the "back" button does what you expect it to... it's fast and it conforms to user expectations, which makes for a much more pleasant user experience than with the script working.

    As for styling the displayed image with borders and annotations, that's perfectly simple to do with straightforward HTML and CSS techniques, which still work if you've got javascript turned off.

    Pages that don't work like you expect them to and stuff that deliberately delays access to content are not things that will encourage visitors to a website to return. If they can find comparable content on a website that does not pose pointless accessibility problems then it is that other website which they will prefer.

    So unless you actually *want* to discourage visitors to your site, I don't see the point of this.

Leave Your Comment

Recent Waves

Recent Comments