Various minor Avatar fixes, but pretty necessary.

One typing thing. And a missed exception case.

Get src from displayUrl() instead of url for example.
This commit is contained in:
Mikael Nordfeldth 2013-10-02 14:37:10 +02:00
parent ba5e90164c
commit 7979918ba9
7 changed files with 23 additions and 38 deletions

View File

@ -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);
}

View File

@ -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));

View File

@ -141,15 +141,15 @@ class FoafAction extends Action
$this->elementEnd('based_near');
}
try {
$avatar = Avatar::getOriginal($this->profile);
if ($avatar) {
$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,

View File

@ -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

View File

@ -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) {

View File

@ -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));

View File

@ -722,17 +722,16 @@ class ActivityObject
if ($this->type == ActivityObject::PERSON
|| $this->type == ActivityObject::GROUP) {
foreach ($this->avatarLinks as $avatar) {
$xo->element(
'link', array(
foreach ($this->avatarLinks as $alink) {
$xo->element('link',
array(
'rel' => 'avatar',
'type' => $avatar->type,
'media:width' => $avatar->width,
'media:height' => $avatar->height,
'href' => $avatar->url
'type' => $alink->type,
'media:width' => $alink->width,
'media:height' => $alink->height,
'href' => $alink->url,
),
null
);
null);
}
}