Support » Fixing WordPress » Stripping the title attribute from images

  • Hi All,

    So, I’m basically just trying to strip the title attribute which is returned by default from all of the images on my site (including those outside of the_content), and I’m drawing a blank –

    Due to some reading around, I suspect that I have to filter
    wp_get_attachment_image_attributes (see here) in functions.php, but my PHP isn’t sufficient to actually modify it in a way that returns what I’m looking for…

    Any help would be much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi ncott,

    Here is the code which you can paste into the function.php file in your theme folder.

    function my_img_title_filter($attr) {
    	unset($attr['title']);
    	return $attr;
    	}
    add_filter( 'wp_get_attachment_image_attributes', 'my_img_title_filter' );

    Perfect. Thanks very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stripping the title attribute from images’ is closed to new replies.