Colorbox - Adding a hyperlink to the photo's caption

This tutorial will show you how to add a link to the caption of an image that appears in the Colorbox pop up.

Here's what I mean:

Screenshot of caption link

My images are individual nodes so they do have a unique URL which contains the photos' description, comments and other information. I thought it would be easy to have the photo caption link to the node page but after a few hours of hacking away at the theme_colorbox_image_formatter() function, I realized that the image title (ie. caption) is being generated via JavaScript and it wouldn't be possible to link to the node (at least not when rendering the colorbox gallery via Views).

So, here's how I turned the photo caption into a link to the node page.

I'm using:
Views 7.x-3.3
Colorbox 7.x-1.2

1. Copy the following functions from colorbox.theme.inc (/sites/all/modules/colorbox/colorbox.theme.inc) into your theme's template.php file:

- theme_colorbox_image_formatter()
- theme_colorbox_imagefield()

2. Change "theme_" to your theme's name. In my case, I'm using the Corolla theme so I changed the previous function names to:

- corolla_colorbox_image_formatter()
- corolla_colorbox_imagefield()

3. In the corolla_colorbox_image_formatter() function change this:

Subscribe with RSS Subscribe to RSS - hyperlink