<?php
$gravatar_link = 'http://www.gravatar.com/avatar/' . md5($comment_author_email) . '?s=32';
echo '<img src="' . $gravatar_link . '" />';
?>
The variable $comment_author_email
would be a string of a valid email address. If the email isn’t in the Gravatar database, it will return a default graphic. $comment_author_email
is the default WordPress variable that populates from a cookie for people who have previously commented (if the theme supports it).
Thanks! This is exactly what I was looking for!
Really cool tip Sir i was searching same from centuries. Thanks a lot
Thanks a million, I noticed that WordPress had the ability to show Avatars, But i couldn’t for the life of me work out how to add them. Saw this post, and thought I would give it a go. :)
Also, this should post my gravatar i presume?
Cool :D One module goes trash bin :)
Thanks
Great !!!
its great
this is cool, how would someone do a check that gravatar is reachable or is online and provide a fallback if gravatar isn’t reachable or user is offline?
What if the use has no picture in gravatar? How to automatically display default avatar image in that case?
It should use the default gravatar by default, but if not, then you can go with the more standard way to fetch them: https://codex.wordpress.org/Function_Reference/get_avatar