A guy, a blog and the internet
Site Updates – Gravatar
Well added support for gravatars this morning, man these things are pretty kewl.
If you have are registered on http://site.gravatar.com/ and you use your email address when leaving a comment, then your gravitar is shown next to your name…
This was suprisingly simple to setup…
I used MySQL to supply me the MD5 but the solution on there site is:
PHP
Implementing gravatars with PHP is quite simple. PHP provides both md5() and urlencode() functions, allowing us to create the gravatar URL with ease. Assume the following data:
$email = "someone@somewhere.com";
$default = "http://www.somewhere.com/homestar.jpg";
$size = 40;
You can construct your gravatar url with the following php code:
$grav_url = "http://www.gravatar.com/avatar.php?".
"gravatar_id=".md5($email).
"&default=".urlencode($default).
"&size=".$size;
Once the gravatar URL is created, you can output it whenever you please:
print("<img src=\"{$grav_url}\" alt=\"\" />");
| Print article | This entry was posted by Clifford W. Hansen on December 2, 2007 at 23:12:00, and is filed under PHP, Web. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.