Constructing & Using Gravatar URIs
3 posts • Page 1 of 1
Constructing & Using Gravatar URIs
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:
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!
Enjoy!
[source: http://en.gravatar.com/site/implement/url, personal knowledge/use as well!]
---
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!
Enjoy!
[source: http://en.gravatar.com/site/implement/url, personal knowledge/use as well!]
- casey
- Newbie
- Posts: 16
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests