Posted by: Vincent on: January 5, 2012
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!
WordPress Quick Tips is a blog supplying great tips about WordPress.
We hope to create a great knowledge resource for WordPress developers as well as serving a reminder for all the forgetful ones.
The blog is created and run by Vincent of Oakwood Creative
Clone this site at WordPress.com
Theme: Albeo by Design Disease.