0

I'm searching for a resolution which can add title attribute (title="") to a WordPress gallery. Now, the code looks like this:

<img width="400" height="400" src="http://example.com/wp-content/uploads/2017/03/myimage-400x400.jpg" class="attachment-thumbnail size-thumbnail" alt="image alt desc">

I specified the title in the media editor, but the attribute is not showing in the image tag.

2
  • 1
    Are these images being added via the [gallery] shortcode or are you referring to inserting individual images? Note that the output will be different (and therefore, the answer) depending on how the images are being inserted into the post (and even whether they contain a caption or not). Commented May 24, 2017 at 19:00
  • @MariuszM I approved the edit from the queue. If you are the same user as the author, please merge your accounts. Commented May 24, 2017 at 20:00

1 Answer 1

0

The 'img' tag is built via the theme code for display on the page. So, you would have to modify the theme code to add to the img tag.

Note that modifying theme code directly is not generally advised, as a theme update will overwrite your changes. "Child" themes are best used for this modification.

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.