I use Wp 3.4.2 and Featured Image. After I feel the Title, Alternate Text and publish the post, html code looks like this:

<img width="214" height="300" title="" alt="Test" class="frame wp-post-image" src="http://www.website.com/wp-content/uploads/2013/02/Test-214x300.jpg">

Is there a way to fix this?

  • What do you mean by "not the WP 3.5 issue"? ::: Does this happens right after you "Insert into Post"? ::: Make sure the theme or some plugin is not responsible for this.
    – brasofilo
    Commented Feb 7, 2013 at 16:29

1 Answer 1


you can try this filter

add_filter('wp_get_attachment_image_attributes', 'my_img_title', 10, 2);
function my_img_title($attr, $attachment = null){
    $attr['title'] = get_post($attachment->ID)->post_title;
        return $attr;

It should give the the extra title attribute in the img tag.

You can also use the 'post_thumbnail_html' filter to edit the html output.

ps: here is a similar question:

Display info from custom fields in all images' HTML

  • Yes, this is the solution. PROBLEM SOLVED!
    – Blanka
    Commented Feb 7, 2013 at 19:06
  • For brasofilo: WP 3.5 has a problem with title images. See this: socialmedia101.artizondigital.com/2013/02/…
    – Blanka
    Commented Feb 7, 2013 at 19:14
  • ok great ;-) (maybe you should mark the question solved)
    – birgire
    Commented Feb 8, 2013 at 0:09
  • How to mark a question solved, birgire? I don't know how. :(
    – Blanka
    Commented Feb 8, 2013 at 6:47

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.