Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 Feb 7 '13 at 16:29
add comment

1 Answer

up vote 0 down vote accepted

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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