Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm building a site that has thumbnail with titles... (web design request)...
How can I display the image title under each thumbnail?
Comments
Comment #1
marco_cruz CreditAttribution: marco_cruz commentedAnswering to myself (and someone who needs it):
1. Find the file colorbox.theme.inc and open it
2. Find line 112
3. Change it from:
return l($image, $variables['path'], $options);
to
return l($image, $variables['path'], $options) . $variables['title'] ;
Comment #2
frjo CreditAttribution: frjo commentedYou do not want to edit the colorbox.theme.inc directly. It will make upgrading the module a hassel.
What you do is copy the theme_colorbox_imagefield() function to the template.php file in your theme, rename it to nameofmytheme_colorbox_imagefield() and make the changes you want there.
Now you can upgrade the Colorbox module as normal and your customisation is safe in the template.php file.
This is how you override any theme function.
Comment #3
jonodunnett CreditAttribution: jonodunnett commentedFor me the function to modify was theme_colorbox_imagefield($variables). If I directly hack the Colorbox module then it works as intended (titles now show) but if I copy the function to template.php in my theme then I get an error:
"Fatal error: Cannot redeclare theme_colorbox_imagefield() (previously declared in C:\wamp\www\D7\sites\all\themes...."
Any ideas what the problem is? if possible I would prefer to do things the right way and not hack outside of my theme folder...
Useful fix though, thanks!
Comment #4
elianmVery useful, thanks for the solution.