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.

Comments

Jonasvh’s picture

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

mugginsoft.net’s picture

The onclick anchor will cause the page to redisplay unless the event returns false.


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

Alternately we can use JavaScript:void(0); as the anchor target.


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

tachis’s picture

It works for me. Is there any way to make the link automatically start the slideshow even if this is disabled in the normal lightbox view?

JCL324’s picture

This does not work for me, I keep getting "Lighbox is not defined". What am I missing?

JCL

amolotovnik’s picture

Hi,
for me works this solution. I hope it will be helpfull for someone

(function ($) {
	$(document).ready(function() { 
	    $('a.lb').live("click", function(){ // .live() because of jquery version 1.4. In newer versions is recommended to use .on()
                    Lightbox.start(this, true, false, false, false); return false; // Direct call instead of trigger
		    return false;
	    });
	});
})(jQuery);
</script>
eSzeL’s picture

Thank You!