2008
11.30

using the Gravatar in WordPress.

Gravatar is Globally Recognized Avatar, It can be identified by your email address or ID in http://www.gravatar.com/.

The Great WordPress supported gravatar system above version 2.5, we can show the avator icon by the function get_avatar(); I patch my theme (comment.php) this afternoon, and let it supported the gravatar icon. if you wants your WordPress to support the gravatar, please follow the steps:

first, if you don’t have a gravatar, please sign up for one.

second, modify your comment.php in your /wp-content/themes/your_theme/comment.php and insert the function get_avatar(); .

for an example:


    echo get_avatar( $comment, $size = '48', $default = 'url' );

    //   the $comment: just fill the prop. with the variable $comment.
    //   the $size: max is 512
    //   the $default: the default image url, you also can adjust in from your control panel.

WordPress also provided for backwards compatibility(from codex.wordpress.org):


    if (function_exists('get_avatar'))
    {
       echo get_avatar($email);
    }
    else
    {
       //alternate gravatar code for < 2.5
       $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5($email) . "&default=" . urlencode($default) . "&size=" . $size;
       echo "<img src='$grav_url'/>";
    }

done! that’s it!

you can learn more at: Using Gravatars

by the way, if you want to test your gravatar, you may leave a comment above this post.

3 comments so far

Add Your Comment
  1. test, test for gravatar.

  2. Yes, sign up an account, upload you “avatar”, and fill your email address when you post an article. then you waill see your avatar.

  3. Test my global recognized avatar.

:D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>