Constructing & Using Gravatar URIs

Show us how it's done

Constructing & Using Gravatar URIs

Postby casey » Tue May 25, 2010 9:29 pm

I made this for Lisa, thought it may be useful to others.
To get a gravatar URL use PHP to get an MD5 of their email LOWERCASE.
so. my email is so my md5 of it is b87c452ff439616a197f9dace8847813
Take the md5 hash pop it on the back of this URL: and use the jpg extension and you've constructed a url.
So my url is. ... 847813.jpg
To get that using PHP:
Code: Select all
$email = md5("myemail@mydomain.mytld");
$construct = "".$email.".jpg";
echo "My gravatar URL is ".$contstruct;

If we're going to use it in a blog, we may want to change the size. To do add ?s={size_in_pixels}
so for example to make that gravatar 150 pixels use this code ... .jpg?s=150
(also note max size is 512px, min is 1px).

Gravatars have ratings as well. Lets say I want only things PG and under. I'd use ?r=pg
(the ratings are: g, pg, r, x . you are telling the the max to show, so like x would let any of them be shown etc) ... 3.jpg?r=pg
Let's now say I want to have my gravatar 50 pixels and max rating of PG.
I'd use. ... ?s=50&r=pg
So here is my gravatar in 50 pixels and 150 pixels! :)
[source:, personal knowledge/use as well!]
Posts: 16

Re: Constructing & Using Gravatar URIs

Postby olivia » Tue Jul 20, 2010 9:21 am

Nice tutorial!
User avatar
Posts: 521
Location: USA

Re: Constructing & Using Gravatar URIs

Postby casey » Thu Jul 22, 2010 8:51 am

Thanks a ton, Olivia (-:
Posts: 16

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB
©, done my way - Testimonials - Contact - Sitemap - Back to Top