This guide helps you easily fix missing Gravatar ALT and title tags that some user experience with their sites. Fixing the missing Gravatar alt description is very easy and you can make this fix without any plugins, all you will need to do is add a function to your MU plugins or to your theme functions.php. You can also add this function using the My Custom Functions plugin, this might be the best option if you don’t fully understand the functions.php file or MU plugins.

Fixing the missing Gravatar is important to make sure your site passes an SEO audit, missing alt descriptions will flag as an error in an SEO audit.


/**
* Gravatar Alt Fix
*/
function lakewood_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;
}
add_filter('get_avatar','lakewood_gravatar_alt');

The above function will pull the author display name to use in the alt description and title tag. I have also added some extra text to make it more readable, you can change this.