Blog's commenting user's alt image


#1

I am facing an issue, there is a error is showing in my site, that have an error missing alt tag, and when i am checking the page i got that who persons have commented on my site, there is alt missing… So, how can i resolve it?


#2

If it is about WordPress Gravatar, you may fix it by adding below function using Code Snippet plugin.

function gatttf_replace_content( $text ) {

  if ( have_comments() ) {
    $alt = get_comment_author();
  } else {
    $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','gatttf_replace_content' );


This will add alt tags to the Gravatar images automatically.