A gravatar is a globally recognized avatar, which means that your avatar is stored in one place and it will appear on several websites, blogs, forums (which support gravatars). Whenever you change your avatar it will be updated on your existing comments, forum posts, etc. It’s a great service! Now if you know what a gravatar is you might want to use it in one of your classic ASP applications. This post describes how to solve this simple problem…
Grabbing a gravatar is simple. It’s nothing more than writing a simple
img-tag. The URL for the image points to the gravatar server and includes the email adress of the user whose avatar you want to display. Because everyone could simply grab the plain-text email from the html sourcecode we need to hash it with a MD5 hash. This keeps spammers away. Example of the html
this example would show my personal gravatar which you should see on the left side. Now you have recognized that with classic ASP there is no built-in MD5 hasher. For this reason we need to use our own which you can download at the bottom of the post. Using our MD5 hasher we can easily generate gravatars from within ASP. Here is the code …
<img src="http://www.gravatar.com/avatar.php?gravatar_id=&default=” />
Finished! Thats all we need. There are other optional options which you could provide for the gravatar like e.g. the size of the gravatar. Get more details about the options here.
For all of you who are looking for asp.net implementation of gravatar, please check Peter Bucher’s gravatar C# control. Unfortunately the article is in german, but source code speaks for itself 😉