We all know that having an ALT tag value for images is very important for SEO. If you run an SEO analysis on your website, you might have encountered the issue of the ALT tag value missing from Gravatar images.
This issue is very common and can be fixed easily. So let’s learn How To Fix Missing Gravatar Alt Tag Value In WordPress in this article.
Before making any changes to any files, please take a full website backup ( Don’t depend on hosting providers’ backups)
Table of Contents
What Is ALT Tag In Images?
The ALT tag value is used by search engines to know what the image is all about. Like text content, Google can’t read pictures and check the content. What it can read is the ALT tag value.
For example, if you write “SEO coaching” as an ALT tag value for an image, then Google will understand that the image is all about SEO coaching and will show the image in the search results for that keyword.
One more benefit of adding an ALT tag value is that if the image can not be displayed for some reason, then the ALT tag value will be shown to the visitor instead of the image.
So your visitor will come to know that they have a missing image about that ALT tag value.
How To Fix Missing Gravatar Alt Tag Value In WordPress?
If you use the default author profile, WordPress will fetch the author image from the Gravatar account if it exists with the same email ID the author uses.
Gravatar does not add any ALT tag value to images by default, although it is an SEO concern. On top of that, there is no direct way of adding an ALT tag value for gravatar images.
That is why you will see the ALT tag missing issue for gravatar images.
Fixing this issue is very easy if you have a basic knowledge of PHP and know how to access and edit your website files.
It is always preferable to use a child theme and make those changes so that your changes will remain intact, even if there are any theme updates.
As you can see below, I have a list of missing ALT tags, and all issues are due to the gravatar image.

Although SEO tools like Ahrefs or Semrush do not show this as a serious concern, we should fix it as it could be a concern in ranking high in Google search results.
You need to head over to the function.php file in the child theme directory and add the following code.
What it does is add an Alt tag value to the gravatar image. The alt tag value is “Profile Picture For XXX,” where XXX is the person’s name. In my case, it will be “Profile Picture For Rajib,” as I am writing the post.
/**
* Gravatar Alt Fix
* https://www.rianstech.com/review/fix-missing-gravatar-alt-tag-value/
*/
function gravatar_alt($text) {
$alt = get_the_author_meta( 'display_name' );
$text = str_replace('alt=\'\'', 'alt=\'Profile Picture For '.$alt.'\' title=\'Gravatar for '.$alt.'\'',$text);
return $text;
}
add_filter('get_avatar','gravatar_alt');
Once you add these pieces of code, save the file, clear all cache, including the browser cache, and re-run the SEO analysis. The problem will be solved.