Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Wednesday, November 6, 2019

PHP Snippet : Display Gravatar Image Function


Here is a simple PHP function you could use to display the Gravatar image for a user based on their email address. It allows setting a css class for the image tag as well as specifying the size of the image to display.

function displayGravatarImage($email_address, $class = '', $size = 32) {
 
  if(!filter_var($email_address, FILTER_VALIDATE_EMAIL)) {
    throw new Exception("Invalid email address");
    return FALSE;
  }
 
  $gravatar_link = 'http://www.gravatar.com/avatar/' . md5($email_address) . '?s='.$size;
 
  echo '<img class="' . $class . '" src="' . $gravatar_link . '" />';
}


As you can see it is pretty simple and straightforward. We validate the email address and then generate the appropriate gravatar image url before outputting.

You could easily extend this function to include extra markup to suit your purpose, or even just to return the link rather than output it.

Tuesday, April 21, 2015

CGTextures revamped


I've been experimenting with 3d modelling and programming and one of the best resources for textures I had come across is CGTextures. They have recently released their new site at

http://www.textures.com/

All new design with the same features and great selection of textures.

Check it out for a free texture daily.