Viewing 4 replies - 1 through 4 (of 4 total)
  • I suppose it is a theme specific gallery? The way the source code is rendered, there is only the alt attribute available… Can you not change the alt texts so they match the caption? That would be easiest.

    Otherwise you’d need to edit the theme to start adding the caption as a title attribute to the image links. Or ad some extra javascript snippet that will do this ‘on the fly’ after page load.

    Thread Starter dkarlton

    (@dkarlton)

    Thanks for the info. I have hundreds of photos, so it’s a bit tedious to manually edit all of the alt attributes. I guess I’ll have to spend a little time tweaking the theme. 🙂

    Thread Starter dkarlton

    (@dkarlton)

    RavanH, should it just be a “title” attribute on the <img>-tag?

    Hi dkarlton, no the title attribute is for the tag… <img> tag does not officially have a title attribute at all. Only alt see http://www.w3schools.com/tags/tag_img.asp

    Be aware that you need to (at least) escape single or double quotes that can be inside these captions. Depending on which you are using in the theme template, for example when using title="<?php ... ?>" you will need to prevent any unescaped " (double quote) in the caption output. Else they will break the title attribute. You could use htmlspecialchars or http://codex.wordpress.org/Function_Reference/esc_html for this purpose, unless you would like to show html formatted captions as title. In that case, a simple str_replace might suffice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not showing title’ is closed to new replies.