Closed (duplicate)
Project:
Colorbox
Version:
7.x-2.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2011 at 23:13 UTC
Updated:
24 Sep 2013 at 14:42 UTC
At the bottom of the colorbox windows, images have their Title text displayed. Is there a way I can set this to be images Alt text instead? I don't mind editing a line of code or two in the module to achieve this.
Comments
Comment #1
frjo commentedIf the title is empty Colorbox will use the alt instead. If you always want to use the alt you can implement theme_colorbox_imagefield() in your themes template.php file.
Copy theme_colorbox_imagefield() from the colorbox.theme.inc file and change
to
Remember to clea the Drupal cache so it will pick up the new theme override.
Not tested, this but it should work.
Comment #2
bryancasler commentedMaking that change didn't actually work, even though it looks like it should. It also produced the following notices.
Comment #3
frjo commentedMy bad, $variables['image']['alt'] it should be.
Comment #4
bryancasler commentedThanks so much for helping me with this, #3 seems to have solved the issue half way.
When I have an image upload field and the display is set to colorbox, then this works. When I have an image upload field that is used in combination with the Insert module, this does not work. For some reason the colorbox image field styles when inserted are still using the title and not the alt text.
Comment #5
frjo commentedImages placed with the insert module uses separate functions.
Copy the "colorbox-insert-image.tpl.php" file to your own theme and where it says title="__title__" change it to title="__alt__".
Comment #6
bryancasler commentedCopying the tpl file to my theme and altering it didn't work. However, altering the original tpl file does work. Not sure why that is. Thanks for all your help, it's much appreciated frjo.
Comment #7
frjo commented@animelion, did you clear the Drupal cache after you placed a copy of "colorbox-insert-image.tpl.php" file in your own theme?
The problem with editing the original file is that it will be overwritten next time you update the Colorbox module.
Comment #8
bryancasler commentedJust tried it again to make sure, same results.
Comment #9
frjo commentedIt does work, I just tested it. There is catch however that I had not considered before.
I guess you are using the default admin theme "Seven"? When you add/edit nodes your are using the admin theme so Drupal is looking there for template files.
So adding a copy of "colorbox-insert-image.tpl.php" to "/themes/seven" work but that may also easily get deleted next time you update Drupal core.
The insert module itself must have the same problem, I see if there are any talk there how to solve this.
Comment #10
bryancasler commentedThat makes sense! Thanks for helping me dance around this issue :)
Comment #11
frjo commentedComment #13
woop_light commentedHas this changed in more recent releases of colorbox? I tried following the instructions of overriding the , but couldn't get it to work (no errors or anything, just didn't have any impact). Also, just for testing, I went into the colorbox.theme.inc code and changed the caption section to read
Surprisingly, that didn't have any effect either.
Any help would be much appreciated. The case | switch that I removed when I put that code in there made it seem like there was an option I could select case 'alt' somehow, rather than case 'auto', but I could be totally off here.
Comment #14
hass commentedIf we render a field and "auto" is used we are using ALT if there is not TITLE. Insert should follow the same logics like a field. Aside of this I have now hundreds of images in wysiwyg content without an title defined. Can we read the alt from the image via JS, please?
Comment #15
hass commentedComment #16
frjo commentedSee #2003562: Colorbox title not shown, but ALT exists