2013-07-27 02:15:07 +02:00
|
|
|
|
<?php
|
|
|
|
|
|
2013-09-01 22:04:30 +02:00
|
|
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
|
use Illuminate\Support\Facades\URL;
|
|
|
|
|
|
2013-07-27 02:15:07 +02:00
|
|
|
|
class Gravatar {
|
|
|
|
|
/**
|
|
|
|
|
* Returns a Gravatar URL
|
|
|
|
|
*
|
|
|
|
|
* @param string $email The email address
|
|
|
|
|
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
|
|
|
|
|
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
|
|
|
|
|
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
|
|
|
|
|
* @return Gravatar URL
|
|
|
|
|
* @source http://gravatar.com/site/implement/images/php/
|
|
|
|
|
*/
|
|
|
|
|
public static function getUrl( $email, $s = 80, $d = 'mm', $r = 'g') {
|
2013-09-01 11:55:59 +02:00
|
|
|
|
$url = 'https://www.gravatar.com/avatar/';
|
2013-07-27 02:15:07 +02:00
|
|
|
|
$url .= md5( strtolower( trim( $email ) ) );
|
2013-09-01 22:04:30 +02:00
|
|
|
|
$url .= "?s=$s&r=$r";
|
|
|
|
|
|
|
|
|
|
if (!Config::get('app.debug')) {
|
|
|
|
|
$size = 'normal';
|
|
|
|
|
if ($s == 50)
|
|
|
|
|
$size = 'thumbnail';
|
|
|
|
|
else if ($s == 100)
|
|
|
|
|
$size = 'small';
|
|
|
|
|
|
|
|
|
|
$url .= "&d=" . urlencode(URL::to('/images/icons/profile_' . $size . '.png'));
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-27 02:15:07 +02:00
|
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
}
|