• Development

    Lightbox2 Slideshows with Multiple-value Imagefields

    This is a pretty simple example that illustrates the use of Lightbox2’s slideshow feature. In the example, we have an imagefield that allows an unlimited number of images. We only want to render an imagecache version of the first image that, when clicked, will provide a slideshow with the rest of the images in the field. In the example, our field is called “field_product_images”.

    The two files I’m showing are both within the theme for the site.

    There are a few other options for achieving the same end result, but this seemed easier to explain and execute. Depending on your needs, you may need to make this happen at a deeper level (module) or in a field template/function override. If you have another approach, please post a comment!

    Now, one last thing. If you want to render many of these imagelink slideshows on a single page, you’ll need to give each lightshow group a unique name. In this project I had a views block that rendered many of these products in “node” teaser view. So, I added three more lines to my template.php code to append the node ID onto the end of the group name. I added this code just under (outside of) the foreach loop above.