How To Remove Image Title Tag In WordPress?

      1 Comment on How To Remove Image Title Tag In WordPress?

A title attribute of an image is normally used to show any text when you hover the mouse over the image. In some cases you may want to remove these title tags from your blog. We can do this by three methods.

  1. Install a WordPress Plugin
  2. Edit function.php and add our own code
  3. Using Javascript

1) Install a WordPress plugin

For removing all the title attributes of images from your blog you can use IMG Title Removal plugin. This plugin will filter all the title attribute tags before sending them to the browser. Just install this IMG Title Removal plugin and activate it in your blog. Now please check your blog. You can’t see any titles for your images anymore there.

Click here to download this plugin. And if you need any help regarding plugin installation and activation please visit this article.

2) Edit function.php

This is  the other method. Just add the below php code in to your function.php page.

<?php

add_filter(‘the_content’, ‘remove_titles’);

function remove_titles($txt) {

// Get all title=”…” tags from the html.
$txtresult= array();
preg_match_all(‘|title=”[^”]*”|U’, $txt, $txtresult);

// Replace all occurances with an empty string.
foreach($txtresult[0] as $img_tag) {
$text = str_replace($img_tag, ”, $txt);
}

return $txt;
}
?>

3) Using JavaScript

Another method would be dynamically removing the title attribute after they have been called on the page. Actually title tags are playing a good role in SEO. So if you actually want to remove title tag, then I will recommend this method because this method will only remove the tool tips and the title tags can be seen in html .

Example for using JavaScript:

jQuery(document).ready(function($) {
$('img[title]').each(function() { $(this).removeAttr('title'); });
});

 

About Shino

Shino, the author of this blog is a 28 year old master graduate in Computer Science, a professional programmer and web developer. TechMagics.com is his humble venture to share whatever he knows and learns about programming,technology and web world.

One thought on “How To Remove Image Title Tag In WordPress?

Leave a Reply