Another jQuery Lightbox plugin exists that supports imagesets by default. I am using the newer plugin now and recommend everyone do the same.
- Both releases were at version 0.5, so I thought they were the same. Looking closer at the changelogs, I found this new one by Warren Krewenki to be better maintained and supports imagesets without hacking.
- NOTE: My modification below only applies to the version.
- Be aware that Krewenki’s Lightbox function is called
lightbox, all lowercase. Pinho’s was camelCased as
lightBox. In addition to pointing to the filenames of Krewenki’s new .js and .css files, your initializing function needs to be updated to all lowercase. Most settings don’t carryover either between the two jQuery plugs – although Krewenki’s match to the original Lightbox better – so verify those, too.
The HTML syntax is almost identical between the two lightbox scripts, so I don’t have to recode any IMG tags. However, version 0.5 of the jQuery lightbox plugin does not recognize Lightbox 2 image sets (a group name between square brackets in the rel attribute).
By adding one IF statement to jquery.lightbox-0.5.js, jQuery lightbox plugin can gain this feature. The code below should replace lines 79-82.
The if statement in the above code is the key. The matching elements passed in the jQuery object get added to the image array only if their
rel attributes match the initial
rel attribute of
Then, your initializing function should read like this:
Note the caret character after
rel, which matches all elements having the
rel attribute and values beginning with
lightbox. Also, jQuery’s Selector API documentation says that the “@” before the attribute name has been deprecated as of v1.2. See more under the “Selectors > Attribute Filters” section of jQuery documentation.
Maybe there is a more elegant way to compare elements that doesn’t require matching the
rel attributes. But, to retain the same HTML syntax for those converting from the Prototype/script.aculo.us script to jQuery plugin, this hack will do nicely.