Using Lightbox2 with dynamically created content and "start slideshow" link

Last updated on
30 April 2025

When using Lightbox2 in image gallery settings you may want a "Start Slideshow" link to appear at the top of the image gallery. Normally this isn't a problem as you can just add a link, with a Lightbox rel attribute, to the first image in the gallery. However, with dynamically created content, such as that created by Views, it's impossible to know the path of the first image. The following link will provide this feature for you:

<a href="#" onclick="Lightbox.triggerLightbox('lightshow', 'groupname');">Start Slideshow</a>

The first parameter to triggerLightbox() is the rel attribute in use on the images. The second param is optional and is the name of the group you are using to make your image sets. If the content is generated automatically, you may need to view the page source to determine this group name.

If you use the Image module so that every image is one node, then use 'node_images' as the groupname.

For Views, the rel grouping is determined partially by your settings under the "CCK display settings" section on admin/settings/lightbox2. For example, if you configure lightbox2 to group imagefields by just their field name and your imagefield has a machine-readable name of "field_testimage", then you should call Lightbox.triggerLightbox('lightshow', 'field_testimage');.

Note, if you're entering this link with an onclick attribute, you will need to use the "Full HTML" input format. For security reasons, it is recommended that you don't allow untrusted users on your site access to this input format.

Help improve this page

Page status: Not set

You can: