Gravatars in Blue Zinfindel Theme

For a while I have meant to do this. Here I am with insomnia, so here goes… I have implemented Gravatars for the this Blue Zinfindel theme.

Here is coding I used to implement it to this theme’s comments.php (WP Design > Theme Editor > Comments). Normal text is for context. Bold is what I added.

<li class=”<?php echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>
<?php echo get_avatar(get_comment_author_email(), ’32’); ?>
<?php comment_author_link() ?>

The first place I saw to provide a function rather than a variable is the weblog tools collection post on gravatars. The above is their recommendation with size 32 image. I picked this size because it is the size of the icon inside the WP admin (tested 64, 48, and 30 with 30 seeming about right).

Once I decided to do it, it took me about an hour to find an example using get_comment_author_email() instead of $comments or $id_or_email. It’s easy to implement.

Gravatars

Probably I missed or didn’t understand the announcement.

For the past month or so, I’ve noticed all these comments with the poster’s picture next to it on various blogs. I knew them to be WordPress blogs. I noticed my own WP had some default icon in the admin user interface. Today I finally put it all together.

A recent WordPress version incorporated Globally Recognized Avatars into the main code. (They are also known as GRAvatars) Using a hash on the email address, it locates a WordPress commenter’s 96×96 picture for including in the comment. Naturally, you need to register your email account with the gravatar service.

So, now many of you get to see my ugly mug!

Zemanta Pixie