0

I just can't get how to do this. When inserting a gallery I have this output:

<a href="path_to_files/image.jpg" title="fancy title">
<img width="150" height="150" src="path_to_files/image-150x150.jpg" class="attachment-thumbnail" alt="fancy alt"/>
</a>

But when inserting single images the title doesn't shows. How to fix that? It's not showing on default wp themes, which is strange.

2
  • Try checking it by deactivating all plugins and using default WordPress theme. Sep 5, 2013 at 17:29
  • @VinodDalvi I've tried this, still title is hiding
    – Nikita
    Sep 5, 2013 at 17:45

2 Answers 2

0

I am assuming you are using the WordPress editor tools to insert your single images. If so, you can just write title="your title" into the markup or go to the visual tab, click the image, hit edit (the photograph icon), and enter a title.

I don't see a way to auto-fill the title, though there may be a way via a filter. I'll check.

2
  • I'm using standard add media button, when selecting an image there is "title" field already as you know, filling it doesn't make title to appear. That's quite strange in the first place. Sure I can edit output and get the desired result, but whats the point of that field then? I'm almost sure that I've missed something.
    – Nikita
    Sep 5, 2013 at 17:49
  • Yes, I know. I can't get the title to show up either and it is a bit odd but I think I understand the logic to it. I'll edit the answer later.
    – s_ha_dum
    Sep 5, 2013 at 20:05
0

In a normal post when you add an image, the WordPress editor adds the title to the img tag, not to the surrounding a tag. If both tags had different titles the title of the img tag would be displayed by the browser, not the title of the a tag.

Using your original example, I have added a title attribute to the img tag:

<a href="path_to_files/image.jpg" title="fancy title">
<img width="150" height="150" src="path_to_files/image-150x150.jpg" class="attachment-thumbnail" title="different fancy title" alt="fancy alt"/>
</a>

You would see "different fancy title" if you hover over the image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.