It is better to add a filter, not changing the core WordPress code. WordPress is very flexible, so that you can filter almost anything, including the post_thumbnail.
Put the filter code in functions.php of your theme file. The filter name is post_thumbnail_html.
add_filter('post_thumbnail_html', 'thumbnail_filter', 99, 5);
function thumbail_filter($html, $post_id, $post_thumbnail_id, $size, $attr) {
// you can alter the resulted HTML here
$html = // remove title from $html
return $html;
}
or you can implement the wp_get_attachment_image_attributes filter, and unset the title attribute. But this method, will eliminate title attribute in all images (not just thumbnail).
Hi guys. I’m having a similar issue.. I’d like to get rid of the size attributes, so I can control the sizes with CSS instead. Suhanto, I assume what you posted is a part of it, but I can’t really figure out the rest.
Any hints are appreciated!
Thread Starter
Dave P.
(@callmedpit)
Suhato – thanks for the tips, still a bit over my head though. I’d still like to know where the actual code is that outputs the HTML that way I can copy it in your above code in the $html variable…and then modify to fit my needs. Hope that makes sense?
Has anybody got an answer to this, as I am too am stuck!
I tried locating the post thumbnail template but there was no mention fo title in there.
Can somebody please help me with this. I have even tried masking the image with another anchored div, still showing though!
Anyone figured it out yet? I just want to use the post title instead of the featured image title on hover.
<?php the_post_thumbnail(array('title' => "")); ?>
More info here: http://codex.ww.wp.xz.cn/Function_Reference/the_post_thumbnail