Gravatars as User icons in PHP

This is an extension of the Gravatar docs, which seemed to be a little lackluster in the PHP department.

	$email = "nickcharlton91@gmail.com";
	$size = "80";
	$gravatar =  "http://www.gravatar.com/avatar/" . md5($email) . "?s={$size}";
        <img src="<?php echo $gravatar ?>" alt="Gravatar" width="<?php echo $size ?>" height="<?php echo $size ?>" />

I’m sure there are similar ways to do this, some most likely more flexible, but this is a great way to slot in user icons in projects. I especially like Github’s way of not making you upload a photo. (Obviously, it’s biggest use is in Blogs, but I digress.)

Posted at 5:26 on 4 th July 2009