I use default WordPress functions to insert images very often. Functions like the_post_thumbnail or wp_get_attachment_image are used in almost every project I do.
By default WordPress adds a title to all of the images printed by these functions, and the title usually is nothing more than the filename.
The result is a lot of title attributes which are pretty much useless and just distracting (while hovering an image for instance).
But thankfully WordPress filters saves us as they often do.
Filter wp_get_attachment_image_attributes and unset the title attribute.
function mytheme_wp_get_attachment_image_attributes( $attr ) { unset($attr['title']); return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'mytheme_wp_get_attachment_image_attributes' );
After that you should be set!
Thankfully stumbled on your post and just wanted to take the time to say thank you 🙂
Saved me quite some time of frustrated hair-pulling there!
Hello Dear Vincent,
How can i do this, using CSS? I have a wordpress.com account and therefore my only chance of changing this is via CSS editor
Thanks
Regards
HI
Where do I put this code in order to make it work, I need to hide all titles on images in a site
I have tried adding in footer.php and header but the text just shows in the page and the title is still there,