WordPress User Gravatar images not displaying. Loading default instead

Not all your images on that page have issues. For example: http://gravatar.com/avatar/619d8e38359241a952a1f9b67f1f36cd?s=60&d=mm

The rest of the images aren’t displaying because the emails you’ve encoded are not recognized with gravatar. The default image shows because you are specifying to use mm when the image can’t be found for your hash. They have several tips for normalizing the email like trim and strtolower to get a better hash hit.

Creating a hash:

  1. Trim leading and trailing whitespace from an email address
  2. Force all characters to lower-case
  3. md5 hash the final string

echo md5( strtolower( trim( “[email protected] ” ) ) );

  $user = get_user_by( 'user_login', $value['user'] );
  $user_email = $user->user_email;

  $url="http://gravatar.com/avatar/" . md5(strtolower(trim($user_email)));
  $url = add_query_arg( array(
    's' => 80,
    'd' => 'mm',
  ), $url );

  $gravatar_url = esc_url_raw( $url );

Gravatar APIDefault Image

Change the default image from mm to https%3A%2F%2Fplacekitten.com%2F256%2F256 by specifying the d parameter.

http://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=250&d=https%3A%2F%2Fplacekitten.com%2F256%2F256

404: do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response

  • mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)
  • identicon: a geometric pattern based on an email hash
  • monsterid: a generated ‘monster’ with different colors, faces, etc
  • wavatar: generated faces with differing features and backgrounds
  • retro: awesome generated, 8-bit arcade-style pixelated faces
  • blank: a transparent PNG image (border added to HTML below for demonstration purposes)

Just remember, not every email has a gravatar which is why the default image exists.