diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-25 18:51:44 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-25 18:51:44 -0800 |
commit | 2feb09f4346e54805f68a9f677f5a94340875d8e (patch) | |
tree | 1c4f2161154853bb672b05755c6ee52df22d5858 /plugins | |
parent | c8ddcbe0d32fb072456587fc554f6b78db672fa7 (diff) |
OStatus: pull best-sized avatar image (96x96 if found, otherwise largest, otherwise if none labeled takes the first)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index ad9170f5b..9b7be4e9a 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -912,8 +912,20 @@ class Ostatus_profile extends Memcached_DataObject protected static function getActivityObjectAvatar($object, $hints=array()) { - if ($object->avatar) { - return $object->avatar; + if ($object->avatarLinks) { + $best = false; + // Take the exact-size avatar, or the largest avatar, or the first avatar if all sizeless + foreach ($object->avatarLinks as $avatar) { + if ($avatar->width == AVATAR_PROFILE_SIZE && $avatar->height = AVATAR_PROFILE_SIZE) { + // Exact match! + $best = $avatar; + break; + } + if (!$best || $avatar->width > $best->width) { + $best = $avatar; + } + } + return $best->url; } else if (array_key_exists('avatar', $hints)) { return $hints['avatar']; } |