Skip to content

Instantly share code, notes, and snippets.

@Piterden
Created July 12, 2016 21:23
Show Gist options
  • Save Piterden/52b13b8b785ec38c81252e6808c94769 to your computer and use it in GitHub Desktop.
Save Piterden/52b13b8b785ec38c81252e6808c94769 to your computer and use it in GitHub Desktop.
[PHP] Get Gravatar Image from user email
<?php
/**
* Generate Gravatar image for user
* @param string
* @return string
*/
public function getImageAttribute($value)
{
$gravemail = md5(
strtolower(
trim($this->email)
)
);
return 'https://www.gravatar.com/avatar/'.$gravemail.'?s=128&d=mm';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment