public static function getGravatarUrl($email, $size = 32, $defaultImage = 'identicon')
    {
        if (empty($email) || self::isValid($email) === false) {
            return null;
        }

        $hash = md5(strtolower(trim($email)));

        $parts = ['scheme' => 'http', 'host' => 'www.gravatar.com'];
        if (Url::isHttps()) {
            $parts = ['scheme' => 'https', 'host' => 'secure.gravatar.com'];
        }

        // Get size
        $size = Vars::limit(Filter::int($size), 32, 2048);

        // Prepare default images
        $defaultImage = trim($defaultImage);
        if (preg_match('/^(http|https)./', $defaultImage)) {
            $defaultImage = urldecode($defaultImage);
        } else {
            $defaultImage = strtolower($defaultImage);
            if (!Arr::in((string)$defaultImage, self::getGravatarBuiltInImages())) {
                $defaultImage = self::getGravatarBuiltInDefaultImage();
            }
        }

        // Build full url
        $parts['path'] = '/avatar/' . $hash . '/';
        $parts['query'] = [
            's' => $size,
            'd' => $defaultImage,
        ];

        return Url::create($parts);
    }
public static function getGravatarUrl($email, $size = 32, $defaultImage = 'identicon')
    {
        if (empty($email) || self::isValid($email) === false) {
            return null;
        }

        $hash = md5(strtolower(trim($email)));

        $parts = ['scheme' => 'http', 'host' => 'www.gravatar.com'];
        if (Url::isHttps()) {
            $parts = ['scheme' => 'https', 'host' => 'secure.gravatar.com'];
        }

        // Get size
        $size = Vars::limit(Filter::int($size), 32, 2048);

        // Prepare default images
        $defaultImage = trim($defaultImage);
        if (preg_match('/^(http|https)./', $defaultImage)) {
            $defaultImage = urldecode($defaultImage);
        } else {
            $defaultImage = strtolower($defaultImage);
            if (!Arr::in((string)$defaultImage, self::getGravatarBuiltInImages())) {
                $defaultImage = self::getGravatarBuiltInDefaultImage();
            }
        }

        // Build full url
        $parts['path'] = '/avatar/' . $hash . '/';
        $parts['query'] = [
            's' => $size,
            'd' => $defaultImage,
        ];

        return Url::create($parts);
    }
public static function getGravatarUrl ( $ email , $ size = 32 , $ defaultImage = 'identicon' ) { if ( empty ( $ email ) || self :: isValid ( $ email ) === false ) { return null ; } $ hash = md5 ( strtolower ( trim ( $ email ) ) ) ; $ parts = [ 'scheme' => 'http' , 'host' => 'www.gravatar.com' ] ; if ( Url :: isHttps ( ) ) { $ parts = [ 'scheme' => 'https' , 'host' => 'secure.gravatar.com' ] ; } // Get size $ size = Vars :: limit ( Filter :: int ( $ size ) , 32 , 2048 ) ; // Prepare default images $ defaultImage = trim ( $ defaultImage ) ; if ( preg_match ( '/^(http|https)./' , $ defaultImage ) ) { $ defaultImage = urldecode ( $ defaultImage ) ; } else { $ defaultImage = strtolower ( $ defaultImage ) ; if ( ! Arr :: in ( ( string ) $ defaultImage , self :: getGravatarBuiltInImages ( ) ) ) { $ defaultImage = self :: getGravatarBuiltInDefaultImage ( ) ; } } // Build full url $ parts [ 'path' ] = '/avatar/' . $ hash . '/' ; $ parts [ 'query' ] = [ 's' => $ size , 'd' => $ defaultImage , ] ; return Url :: create ( $ parts ) ; }
Generates an Gravatar URL.

Size of the image:
* The default size is 32px, and it can be anywhere between 1px up to 2048px.
* If requested any value above the allowed range, then the maximum is applied.
* If requested any value bellow the minimum, then the default is applied.

Default image:
* It can be an URL to an image.
* Or one of built in options that Gravatar has. See Email::getGravatarBuiltInImages().
* If none is defined then a built in default is used. See Email::getGravatarBuiltInDefaultImage().

@param string $email
@param int    $size
@param string $defaultImage
@return null|string
@link http://en.gravatar.com/site/implement/images/
Generates an Gravatar URL .