Integrating Gravatar
3 posts • Page 1 of 1
Integrating Gravatar
I was wondering if it is possible to integrate Gravatar to a regular HTML page, without the use of Wordpress. I'm thinking of adding a Gravatar to my comments-page on my website (it's easier to recognise people
).
Google disappointed me when it couldn't answer, so I'm hoping this forum can help.

Google disappointed me when it couldn't answer, so I'm hoping this forum can help.
-
Lisa - Regular
- Posts: 64
- Location: Norway
Re: Integrating Gravatar
Hello Lisa.
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
Re: Integrating Gravatar
Awesome, this works perfectly. Thank you for taking the time to write this. 

-
Lisa - Regular
- Posts: 64
- Location: Norway
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests