How to Setup Gravatars for your Blog - Plugin Free!

Posted on March 2nd, 2008. 108 Comments so far. You next?

gravatars.png

Recently I’ve added Gravatars to the comments portion of the site. This is extremely easy to as long as you’re not totally useless in terms of copying and pasting. Fear not of messing your blog’s important code up, for this plan is fool proof.

What is a Gravatar?

To start, an avatar is a small image associated with a user, found a lot on forums and are beginning to appear more and more on blogs. Gravatar is a service which allows for “Globally Recognized Avatars“. Basically, you can sign up for the service and your email will be associated with an image you upload. After that, it could’t matter less if you ever visit their site again!

From that point in time, every time you leave a comment at a blog with your valid email address, your image will appear next to your name, providing the owner has added a few simple lines of code.

Their site puts it like this:

Gravatar aims to put a face behind the name. This is the beginning of trust. In the future, Gravatar will be a way to establish trust between producers and consumers on the internet. It will be the next best thing to meeting in person.

- About Gravatar

That might be reaching a little, but by now you should have a brief understanding.

What are the Benefits?

Draw attention to yourself. Most people comment on a website hoping for a little bit of traffic, so it makes sense that using any means within your arm’s reach is beneficial to you. A minute long process of signing up for a service and you get that attention.

People have been known to include scantily clad women, which certainly warrant a few clicks from weary lurkers in the depths of your archives. In short, a Gravatar can do a few things for you:

  • Personalize. Add a picture of yourself and people will see the face behind the name and the words you write.
  • Capture attention. As mentioned above, if you want clicks over a response or any shred of respect, go for shock or surprise value.
  • Get recognized. Comment a lot? Authors and readers like will recognize the avatar of a commenter who consistently posts insightful musings.

In the end, you spend two minutes or so signing up and uploading a picture, and you will see the results soon after.

How to do it

This is a guide custom tailored for WordPress users, but will work on any PHP driven system. Open up comments.php and follow these steps:

  1. Setup your variables. To generate the image you need to send some simple information.<?
    $email = $comment->comment_author_email;
    $default = “”; // link to your default avatar
    $size = 40; // size in pixels squared
    $grav_url = “http://www.gravatar.com/avatar.php?gravatar_id=
    ” . md5($email) . “&default=” . urlencode($default) . “&size=” . $size;
    ?>

    There isn’t much in there to understand. Set the $email variable to whatever works with your system. The one in place works with WordPress. After that, upload an image you want to serve when the user doesn’t have a Gravatar, input a size and you’re good to go.

  2. The HTML code. Next, just insert this code where you want the image to appear:<img src="<?=$grav_url ?>" height="<?=$size ?>" width="<?=$size ?>" alt="User Gravatar" />

    That will display the user’s image.

That’s it! As you can see it won’t take long. You can do this simply and without a WordPress plugin.

What now?

You can now style the image to match your site. You can view a single post on this site to see what it looks like. I have mine setup to give every user 70*70 image that floats to the left of their comment. I think it looks pretty nice, considering the benefits it allows my readers and time it took.

So if you’re reading this, or leave comments on any Gravatar enabled site, I implore you to sign up and get your own image.

76 comments

Leave a Reply

32 Trackbacks