diff --git a/app/library/Gravatar.php b/app/library/Gravatar.php index dd1b69a3..1bb3e071 100644 --- a/app/library/Gravatar.php +++ b/app/library/Gravatar.php @@ -4,26 +4,18 @@ use Illuminate\Support\Facades\URL; 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') { + public static function getUrl($email, $size = 80, $default = null, $rating = 'g') { $url = 'https://www.gravatar.com/avatar/'; $url .= md5( strtolower( trim( $email ) ) ); - $url .= "?s=$s&r=$r"; + $url .= "?s=$size&r=$rating"; - if (!Config::get('app.debug')) { + if ($default != null) + $url .= "&d=" . $default; + else { $size = 'normal'; - if ($s == 50) + if ($size == 50) $size = 'thumbnail'; - else if ($s == 100) + else if ($size == 100) $size = 'small'; $url .= "&d=" . urlencode(URL::to('/images/icons/profile_' . $size . '.png')); diff --git a/app/models/Entities/User.php b/app/models/Entities/User.php index 3d656dda..a16002af 100644 --- a/app/models/Entities/User.php +++ b/app/models/Entities/User.php @@ -66,9 +66,15 @@ if (!$this->uses_gravatar) return $this->avatar->getUrl($type); + if ($this->email == "redacted@example.net") { + return Gravatar::getUrl($this->id . "", Image::$ImageTypes[$type]['width'], "identicon"); + } + $email = $this->gravatar; - if (!strlen($email)) + + if (!strlen($email)) { $email = $this->email; + } return Gravatar::getUrl($email, Image::$ImageTypes[$type]['width']); }