Update – 12 June 2008
An updated version of this post, containing full source for the control and explanation is available here.
Original Post
I just got myself a freshclickmedia.com Gravatar over at gravatar.com. A Gravatar is a little avatar associated with an email address, and quite a few blogs use them to decorate post comments. Signing up is easy – all you need to do is supply an email address, and image, and give your image a content rating.
The source of the gravatar image tag points to gravatar.com’s image generator and includes an MD5 hash of the email address to prevent email harvesting. A ‘max rating’ parameter prevents the display of unsavoury content.
There are a wide number of blogging gravatar plugins, so I decided to write an ASP.NET custom control to do the job. Here I present the control and its features.
Using the Control
To get up and running, the control requires an email address:
<fcm:Gravatar ID='Gravatar1' runat='server' Email='username@domain.com' />
For my email address, I get the following:

And if we look at the generated source:
<a id="Gravatar1" href="http://www.gravatar.com" title="Get your avatar"><img width="80" height="80" src="http://www.gravatar.com/avatar.php?gravatar_id=ccf3b8c638f15d005e5d070aeb1a3923&rating=G&size=80" alt="Gravatar" /></a>
The default produces a hyperlink off to the Gravatar site with a title “Get your avatar”. The image contains the MD5 email hash, a rating of “G” (suitable for all audience types), and a size of 80.
Customisation
The control supports a number of properties supporting the customisation of its output.
Size
The size property of the control can be in the range 1 to 80. If it is outside this range, a default of 80 will be used.
MaxAllowedRating
The ‘highest’ allowed rating of image.
- A G rated gravatar is suitable for display on all websites with any audience type.
- PG rated gravatars contain may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
- R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
- X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.
OutputGravatarSiteLink
True by default, determines whether a hyperlink linking to the gravatar website will be output around the image.
LinkTitle
“Get your avatar” by default, allows the customisation of the ‘title’ attribute of the link (obviously doesn’t apply if OutputGravatarSiteLink property is set to false.)
DefaultImage
URL encoded URL, protocol included, of a GIF, JPEG, or PNG image that should be returned if either the requested email address has no associated gravatar, or that gravatar has a rating higher than is allowed by the “MaxAllowedRating” property.
The code snippet below shows the associated properties.
<fcm:Gravatar ID="Gravatar1" runat="server"
Email="username@domain.com"
DefaultImage="http://www.site.com/default.jpg"
OutputGravatarSiteLink="true" Size="40" />
Download and Get Started
You can download the Gravatar Custom Control here. Once you’ve extracted the assembly from the ZIP file, add to the Visual Studio toolbox by right clicking on the toolbox and selecting “Choose Items” from the context menu. Browse to the assembly (Freshclickmedia.Web.dll), and click “OK” to add.

May 27, 2008 at 11:56 am
Nice work – the customisation is good.
June 2, 2008 at 9:08 pm
Thanks for posting this. Is there any chance you can/will release the source for this? I for one would like to play with the implementation. Thanks.
June 3, 2008 at 4:58 am
Thanks for the comments guys.
@Alex: Yes, I’ll be doing another post very soon containing the code, explanation and control.
Stay tuned.
June 12, 2008 at 1:53 pm
Hi Alex,
a follow-up comment to let you know that I’ve posted another Gravatar post containing code explanation, control and demo solution.
I’d be happy to hear any further comments you have. Check out the new post here.
June 18, 2008 at 5:49 am
Thanks, i will look into this code and maybe use it on my site.
June 20, 2008 at 4:13 am
Easy Peasy
July 5, 2008 at 11:08 pm
Testing my Gravatar.
July 22, 2008 at 6:19 pm
Testing my Gravatar
September 24, 2008 at 6:08 pm
Testing!
September 27, 2008 at 9:48 pm
thanks for sharing
November 12, 2008 at 5:19 am
Nice one. That’ll come in handy
November 15, 2008 at 1:05 am
Thanks for this. You solved a big problem for me. I really appreciate it.
December 1, 2008 at 10:18 am
Thanks; Im looking to implement this in one of my current projects.
January 7, 2009 at 6:38 pm
You and Gravatar are lifesavers! Thank you so much for making this control available.
January 15, 2009 at 6:43 pm
Nice article!
January 25, 2009 at 4:42 pm
Nice
January 28, 2009 at 8:49 pm
Cool
February 7, 2009 at 8:39 am
test my gravatar
February 12, 2009 at 3:54 am
nice one
February 27, 2009 at 3:46 pm
Nice work Fresh Media Dudes and Dudettes
March 5, 2009 at 1:55 am
Thank you so much for a very nice control
March 19, 2009 at 11:05 pm
Cool!
April 10, 2009 at 11:13 pm
test my gravatar
May 11, 2009 at 12:38 pm
TEST
May 12, 2009 at 4:36 am
grt work!!!!
May 21, 2009 at 2:49 am
nice job
May 28, 2009 at 2:10 am
Thanks for a tip!!!
June 11, 2009 at 11:22 pm
good job
July 3, 2009 at 4:36 pm
Just want to test if it works, i’m a newbee to gravatar
July 19, 2009 at 11:13 pm
excellent!
thanks.
July 30, 2009 at 5:09 pm
Good! Thanks!
August 12, 2009 at 5:08 am
Awesome!
Thanks for sharing!
October 3, 2009 at 1:56 pm
Nice job.
ASP.NET MVC?
October 13, 2009 at 3:21 am
Apparently, it works well with ASP.NET MVC too. See this comment.
October 11, 2009 at 11:33 pm
I want to make blog engine and i use it.
Nice Work
October 29, 2009 at 10:22 am
Nice implementation
March 9, 2010 at 2:03 pm
I am building a blog engine and I will use this , thanks!
March 18, 2010 at 5:03 am
thank you, i try to use that!
March 22, 2010 at 6:34 am
nice one..thanks for help
April 8, 2010 at 8:58 am
Thanks, this is a great control!
Pingback: Avatar universali con Gravatar | Mr.Webmaster – Blog
May 10, 2010 at 5:29 am
Thanks!
July 15, 2010 at 11:43 am
Sah-weet. Thanks!
August 9, 2010 at 9:08 am
Great article and thumbs-up for providing the full source for a C# newbie like me.
August 13, 2010 at 5:28 am
great work….
November 14, 2010 at 6:46 pm
Thanks. Its great.
November 17, 2010 at 9:06 am
definately will implement for my blog now
January 14, 2011 at 2:24 am
how should i get or change user’s info?
January 31, 2011 at 1:00 pm
Hi parsa,
You’d most likely use the Email property. Does that help, or do you need more information?
February 17, 2011 at 2:24 am
gr8 article thanx a lot
March 8, 2011 at 12:58 pm
Thanksa lot
March 11, 2011 at 4:34 am
nice
March 19, 2011 at 1:33 pm
Thanks. I have to test it out right away!
March 31, 2011 at 7:03 am
Thank you! Will be using in my project!
May 3, 2011 at 7:50 am
ha
October 26, 2011 at 7:05 am
Testing, testing..
Great Work guys!!!
December 8, 2011 at 3:23 pm
Working great!