Skip to content

Instantly share code, notes, and snippets.

@mkhlil1288
Last active November 14, 2016 10:27
Show Gist options
  • Save mkhlil1288/3f39f447400f7193be5648b3a3f73fe0 to your computer and use it in GitHub Desktop.
Save mkhlil1288/3f39f447400f7193be5648b3a3f73fe0 to your computer and use it in GitHub Desktop.
Get Gravatar with php
public static function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
    $url = 'http://www.gravatar.com/avatar/';
    $url .= md5( strtolower( trim( $email ) ) );
    $url .= "?s=$s&d=$d&r=$r";
    if ( $img ) {
        $url = '<img src="' . $url . '"';
        foreach ( $atts as $key => $val )
            $url .= ' ' . $key . '="' . $val . '"';
        $url .= ' />';
    }
    return $url;
}

ffdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment