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 dke485@ymail.com so my md5 of it is b87c452ff439616a197f9dace8847813
Take the md5 hash pop it on the back of this URL: http://gravatar.com/avatar/ and use the jpg extension and you've constructed a url.
So my url is.
http://gravatar.com/avatar/b87c452ff439 ... 847813.jpg
To get that using PHP:
Code: Select all
<?PHP
$email = md5("myemail@mydomain.mytld");
$construct = "http://gravatar.com/avatar/".$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
http://gravatar.com/avatar/b87c452ff439 ... .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)
http://gravatar.com/avatar/b87c452ff439 ... 3.jpg?r=pg
Let's now say I want to have my gravatar 50 pixels and max rating of PG.
I'd use.
http://gravatar.com/avatar/b87c452ff439 ... ?s=50&r=pg
So here is my gravatar in 50 pixels and 150 pixels! :)
Image
Image
Enjoy!
[source: http://en.gravatar.com/site/implement/url, personal knowledge/use as well!]
casey
Newbie
 
 
Posts: 16

Re: Constructing & Using Gravatar URIs

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

Nice tutorial!
User avatar
olivia
Administrator
 
 
Posts: 521
Location: USA

Re: Constructing & Using Gravatar URIs

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

Thanks a ton, Olivia (-:
casey
Newbie
 
 
Posts: 16


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB
 
© donemyway.com, done my way - Testimonials - Contact - Sitemap - Back to Top