NextGen Gallery: Link to URL

Alex Rabe’s NextGen Gallery is one plugin I couldn’t manage without.  It’s amazingly powerful and adaptable to all sorts of different applications. Sometimes it’s useful to have the image thumbnails in your gallery link to pages, or even to external websites, rather than images. This turns out to be quite easy to accomplish with a minor modification to an existing template.

In the next-gen-gallery/view folder find the standard template: gallery.php or, if you want captions: gallery-caption.php.  Make a copy and rename it  gallery-link.php.  In the thumbnails section of the file look for the line beginning <a href=”<?php echo $image->imageURL ?>”.   Just replace imageURL ? with alttext ?.  The link href should now look like this: “<?php echo $image->alttext ?>”.

Now all you need to do when you want external links for your thumbnails is to add template=link to your gallery shortcode and make sure that you insert the required urls into the image alt/title boxes on the gallery settings page.

I’ve used this approach on this site to showcase our website designs. Thumbnails on the Websites page link directly to the individual sites.

PS.  You can make this work for the NGG image widget as well.
Just find the  link statement in next-gen-gallery/widget.php:
<a href=”‘ . $image->imageURL and change to: a href=”‘ . $image->alttext