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');