From 458871705a6101c9cd19d7bf5793b123a52255bc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 14 Apr 2011 11:38:41 -0400 Subject: [PATCH] Grossly simplify Gravatar plugin --- plugins/Gravatar/GravatarPlugin.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/Gravatar/GravatarPlugin.php b/plugins/Gravatar/GravatarPlugin.php index 256f6b162a..ea91d11e78 100644 --- a/plugins/Gravatar/GravatarPlugin.php +++ b/plugins/Gravatar/GravatarPlugin.php @@ -192,6 +192,22 @@ class GravatarPlugin extends Plugin 'success' => true); } + function onEndProfileGetAvatar($profile, $size, &$avatar) + { + if (empty($avatar)) { + $user = $profile->getUser(); + if (!empty($user) && !empty($user->email)) { + // Fake one! + $avatar = new Avatar(); + $avatar->width = $avatar->height = $size; + $avatar->url = $this->gravatar_url($user->email, $size); + return false; + } + } + + return true; + } + function gravatar_url($email, $size) { $url = "https://secure.gravatar.com/avatar.php?gravatar_id=". @@ -205,7 +221,7 @@ class GravatarPlugin extends Plugin { $versions[] = array('name' => 'Gravatar', 'version' => STATUSNET_VERSION, - 'author' => 'Eric Helgeson', + 'author' => 'Eric Helgeson, Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Gravatar', 'rawdescription' => // TRANS: Plugin decsription.