Fix Missing Gravatar Alt Tag Value


Build your own WordPress Support Plan

Expert, yet affordable WordPress support & maintenance plans.
View our pricing

If you have run an SEO audit on your site you may have noticed you get a few warnings for missing alt tags on your Gravatar images, well that is probably why you are reading this article anyway! This is a very common problem and one that I’m sure WordPress will address in a future update. Until then we have made this quick guide to show you have to add useful alt tags to your user’s Gravatars by using just a simple function.

This guide is very simple but will require you to have some knowledge of PHP, you won’t need to make any changes to the default function so you can just copy and paste. We recommend you place the function below in the child theme functions.php, a must use a plugin, or use WordPress Code Snippets.

1. What Is ALT Tag In Images?

The ALT tag value is for 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.

2. How To Fix Missing Gravatar Alt Tag Value In WordPress?

If you are using the default author profile, WordPress will fetch the author image from the Gravatar account if that exists with the same email ID that the author is using.

By default, Gravatar does not add any ALT tag value to images, 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 your website files and edit those.

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.

3. The Function to add Alt tags to Gravatar images

So this is the function you need to use to add alt tags to your user’s Gravatar images. The function uses the user’s display name to add a relevant alt tag to the Gravatar, in this case, the alt tag would be “Avatar for Adam” as my display name is ‘Adam’.

You need to head over to the function.php file located in the child theme directory and add the following piece of code.

 * Gravatar Alt Fix
function gravatar_alt($text) {
    $alt = get_the_author_meta( 'display_name' );
    $text = str_replace('alt=\'\'', 'alt=\'Avatar for '.$alt.'\' title=\'Gravatar for '.$alt.'\'',$text);
    return $text;

If you need help with this function get a quote for this task today.

Always add an ALT tag in your image to avoid any issue related to SEO or an image not found.

For more information on automatically fixing missing gravatar alt tag value, let us help you accordingly, from start to finish, with one-Time fixes, custom plans, or monthly routines for your WordPress website.

Written By
Founder of WP Helper.
You will also like these articles

Relax Knowing Your WordPress Site Is Secure & Running Smoothly 24/7

Let us manage your WordPress site, everything from security to updates will be taken care of. Support plans also come with dedicated support so we can do anything from adding content to customising your site for you.

Same Day Professional WordPress Support

Get WordPress Support Today

Need help with a single WordPress problem, today? We can help with anything from adding analytics tracking code to site hack recovery. Full money back guarantee on all jobs.

1. Submit a Support Request

Use our support ticket form below to send details of your problem to our developers.

2. Get a Quote

We will review your request and provide a quote within 24 hours (but usually within a few hours).

3. We fix your WordPress problem

Our team will begin fixing your WordPress problem the same day.

4. 100% Money Back Guarantee

If we can’t fix the problem for the amount quoted we will refund you 100%.

  • Do you have a screenshot of the issue or have a copy of the theme or plugin that is at fault? If you want to upload php, html or css please zip first.
    Drop files here or
    Accepted file types: jpg, jpeg, png, pdf, zip, gzip, rar, doc, txt, Max. file size: 15 MB, Max. files: 10.