diff --git a/actions/avatarbynickname.php b/actions/avatarbynickname.php index 5e02a4db34..dc80ec952e 100644 --- a/actions/avatarbynickname.php +++ b/actions/avatarbynickname.php @@ -74,7 +74,7 @@ class AvatarbynicknameAction extends Action if ($size === 'original') { try { $avatar = Avatar::getOriginal($profile); - $url = $avatar->url; + $url = $avatar->displayUrl(); } catch (Exception $e) { $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE); } diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 1f4eec5f5d..401c78a0f5 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -130,7 +130,7 @@ class AvatarsettingsAction extends SettingsAction // TRANS: Header on avatar upload page for thumbnail of originally uploaded avatar (h2). $this->element('h2', null, _("Original")); $this->elementStart('div', array('id'=>'avatar_original_view')); - $this->element('img', array('src' => $original->url, + $this->element('img', array('src' => $original->displayUrl(), 'width' => $original->width, 'height' => $original->height, 'alt' => $user->nickname)); @@ -147,7 +147,7 @@ class AvatarsettingsAction extends SettingsAction // TRANS: Header on avatar upload page for thumbnail of to be used rendition of uploaded avatar (h2). $this->element('h2', null, _("Preview")); $this->elementStart('div', array('id'=>'avatar_preview_view')); - $this->element('img', array('src' => $avatar->url, + $this->element('img', array('src' => $avatar->displayUrl(), 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $user->nickname)); diff --git a/actions/foaf.php b/actions/foaf.php index ee6ef85ef6..94ada859d9 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -141,15 +141,15 @@ class FoafAction extends Action $this->elementEnd('based_near'); } - $avatar = Avatar::getOriginal($this->profile); - if ($avatar) { + try { + $avatar = Avatar::getOriginal($this->profile); $this->elementStart('img'); - $this->elementStart('Image', array('rdf:about' => $avatar->url)); + $this->elementStart('Image', array('rdf:about' => $avatar->displayUrl())); foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) { try { - $scaled = Avatar::getOriginal($this->profile); + $scaled = $this->profile->getAvatar($size); $this->elementStart('thumbnail'); - $this->element('Image', array('rdf:about' => $scaled->url)); + $this->element('Image', array('rdf:about' => $scaled->displayUrl())); $this->elementEnd('thumbnail'); } catch (Exception $e) { // This avatar did not exist @@ -157,6 +157,8 @@ class FoafAction extends Action } $this->elementEnd('Image'); $this->elementEnd('img'); + } catch (Exception $e) { + // No avatar for this user! } $person = $this->showMicrobloggingAccount($this->profile, diff --git a/actions/userrss.php b/actions/userrss.php index 239b5e5174..3a7332088d 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -100,14 +100,8 @@ class UserrssAction extends Rss10Action function getImage() { - $user = $this->user; - $profile = $user->getProfile(); - try { - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - return $avatar->url; - } catch (Exception $e) { - return null; - } + $profile = $this->user->getProfile(); + return $profile->avatarUrl(AVATAR_PROFILE_SIZE); } // override parent to add X-SUP-ID URL diff --git a/classes/Avatar.php b/classes/Avatar.php index 782899de79..9c5d97ebbf 100644 --- a/classes/Avatar.php +++ b/classes/Avatar.php @@ -92,7 +92,7 @@ class Avatar extends Managed_DataObject return $avatar; } - public static function hasOriginal($profile) { + public static function hasOriginal(Profile $profile) { try { $avatar = Avatar::getOriginal($profile); } catch (NoResultException $e) { diff --git a/classes/Profile.php b/classes/Profile.php index afb3df6a5b..eced9bd47f 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -177,16 +177,6 @@ class Profile extends Managed_DataObject } } - // For backwards compatibility only! - public function getOriginalAvatar() - { - try { - return Avatar::getOriginal($this); - } catch (Exception $e) { - return null; - } - } - function setOriginal($filename) { $imagefile = new ImageFile($this->id, Avatar::path($filename)); diff --git a/lib/activityobject.php b/lib/activityobject.php index 102f3369b0..b45a8e6e78 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -722,17 +722,16 @@ class ActivityObject if ($this->type == ActivityObject::PERSON || $this->type == ActivityObject::GROUP) { - foreach ($this->avatarLinks as $avatar) { - $xo->element( - 'link', array( - 'rel' => 'avatar', - 'type' => $avatar->type, - 'media:width' => $avatar->width, - 'media:height' => $avatar->height, - 'href' => $avatar->url - ), - null - ); + foreach ($this->avatarLinks as $alink) { + $xo->element('link', + array( + 'rel' => 'avatar', + 'type' => $alink->type, + 'media:width' => $alink->width, + 'media:height' => $alink->height, + 'href' => $alink->url, + ), + null); } }