Menu Close

How to fix – IMG tag does not have an ALT attribute?

0
(0)

Add below codes on your function.php file and fix the image alt attribute missing error.

function code_gravatar_alt($codeGravatar) {
	if (have_comments()) {
		$alt = get_comment_author();
	}
	else {
		$alt = get_the_author_meta('display_name');
	}
	$codeGravatar = str_replace('alt=\'\'', 'alt=\'Avatar for ' . $alt . '\' title=\'Gravatar for ' . $alt . '\'', $codeGravatar);
	return $codeGravatar;
}
add_filter('get_avatar', 'code_gravatar_alt'); 

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Share

Posted in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *

You can also read...