WebReference.com logo
tip archive  •   about  •   sitemap  •   contact  •   jobs  •   write for us  •   subscribe

Shedding Some Light on Lightbox

By

Social Bookmark

Data Center Architect
The Computer Merchant, Ltd
US-MA-chelsea

Justtechjobs.com Post A Job | Post A Resume


Hello and welcome to the first part of what I hope will be an interesting series of articles on the various implementations of Lightbox.

What is Lightbox?

OK, consider this. On your homepage, you want to put up five or six images. Now if they are nice and large, the page will take forever to load. Chances are that visitors will be put off by how long it is taking for the page to load and move on to another website.

You could reduce the load time by only showing thumbnails of the images, but then the visitors miss out on the details in the pictures.

Now what if I told you that you can keep the load time of the page low and also show the images in full size? Load the page with the thumbnails, and when the user clicks on any thumbnail, the browser downloads the full size version of the image and displays it.

That's what Lightbox is all about. It is a fancy name given to a simple solution to a common problem. It has been created by Lokesh Dhakar. Many people have implemented the same concept with minor variations. Lightbox uses the Prototype framework and the Scriptaculous Effects library. Similarly, there is an implementation that uses the jQuery library. Let us see how you can use Lightbox on your website.

Lightbox 2

Lightbox 2 is version 2 of Lightbox. You can download the library here. Here is a list of features of Lightbox 2:

Examples

Single Photos

Photo Album

How to Use

  1. Include Javascript files.
    Lightbox uses the Prototype framework and the Scriptaculous Effects library. We need to include them as well as the Lightbox library.


  2. Include CSS files.
    Include the style sheet for styling the Lightbox.


  3. Activate Lightbox.
    To activate Lightbox, you need to add rel="lightbox" attribute to any link tag. For example:


    If you have a set of images and you want to display them in slideshow mode, use the following code:

Thats it!

The general syntax for the Lightbox is:

I would like to bring the three attributes of the link tag to your notice:

Configure

Lightbox v2.04 allows you to customize a bunch of things. Let us look at the configurable parameters. To set these parameters, you need to edit the lightboxEx.js file.

If you want to use a different graphic when the slideshow is loading, you can change the path of fileLoadingImage in the same file. While Lightbox allows you to tweak the parameters mentioned above, it has its limitations.

When all is said and done, Lightbox is a very handy component. Just by including 4 files and adding rel="lightbox" to the link tags, we can display as many images on our web page without worrying about increasing the load time of the page.

Until Next Time ...

This wraps up the first session. We saw that Lightbox 2 supports only images. In the next part, we will look at another implementation that allows us to embed Flash videos and other HTML components into the Lightbox window.

Recent Articles

WebReference.com site name
Building a Banking Application Home Page with OOP
Mixing Scripting Languages
Review: phpFox, a Social Networking CMS with all the Bells and Whistles
internet.com site name
Enterprise 2.0: Social Networking in the Cloud
BroadSoft Marketplace Hastens Pace of Telephony Innovation
Review: HTC Hero for Sprint


internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs