How can I fetch anyone’s gravatar image?

I need to show users gravatar image on a custom profile page that am making.

I have so far integrated the option of Facebook Profile Pic (which automatically gets grabbed) and also am allowing user to assign his/her own photo (on wish).

What I need to do is, if person do not comes from FB, then maybe his email or something should be used to see if he/she has a gravatar, if yes then display it. How can I do that?


1 Answer 1


You can use get_avatar. The following example prints an avatar in 96 px, assuming that you have the user id stored in $user_id, and prints a fallback user.png if no such user or image could be found.

echo get_avatar($user_id, 96, get_stylesheet_directory_uri() . '/images/user.png');
  • i will implement it asap, and will revert back. thanks for the reply.
    – vajrasar
    Commented Feb 16, 2013 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.