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:
parent
ba5e90164c
commit
7979918ba9
@ -74,7 +74,7 @@ class AvatarbynicknameAction extends Action
|
|||||||
if ($size === 'original') {
|
if ($size === 'original') {
|
||||||
try {
|
try {
|
||||||
$avatar = Avatar::getOriginal($profile);
|
$avatar = Avatar::getOriginal($profile);
|
||||||
$url = $avatar->url;
|
$url = $avatar->displayUrl();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
$url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class AvatarsettingsAction extends SettingsAction
|
|||||||
// TRANS: Header on avatar upload page for thumbnail of originally uploaded avatar (h2).
|
// TRANS: Header on avatar upload page for thumbnail of originally uploaded avatar (h2).
|
||||||
$this->element('h2', null, _("Original"));
|
$this->element('h2', null, _("Original"));
|
||||||
$this->elementStart('div', array('id'=>'avatar_original_view'));
|
$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,
|
'width' => $original->width,
|
||||||
'height' => $original->height,
|
'height' => $original->height,
|
||||||
'alt' => $user->nickname));
|
'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).
|
// TRANS: Header on avatar upload page for thumbnail of to be used rendition of uploaded avatar (h2).
|
||||||
$this->element('h2', null, _("Preview"));
|
$this->element('h2', null, _("Preview"));
|
||||||
$this->elementStart('div', array('id'=>'avatar_preview_view'));
|
$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,
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
'alt' => $user->nickname));
|
'alt' => $user->nickname));
|
||||||
|
@ -141,15 +141,15 @@ class FoafAction extends Action
|
|||||||
$this->elementEnd('based_near');
|
$this->elementEnd('based_near');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$avatar = Avatar::getOriginal($this->profile);
|
$avatar = Avatar::getOriginal($this->profile);
|
||||||
if ($avatar) {
|
|
||||||
$this->elementStart('img');
|
$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) {
|
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
||||||
try {
|
try {
|
||||||
$scaled = Avatar::getOriginal($this->profile);
|
$scaled = $this->profile->getAvatar($size);
|
||||||
$this->elementStart('thumbnail');
|
$this->elementStart('thumbnail');
|
||||||
$this->element('Image', array('rdf:about' => $scaled->url));
|
$this->element('Image', array('rdf:about' => $scaled->displayUrl()));
|
||||||
$this->elementEnd('thumbnail');
|
$this->elementEnd('thumbnail');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// This avatar did not exist
|
// This avatar did not exist
|
||||||
@ -157,6 +157,8 @@ class FoafAction extends Action
|
|||||||
}
|
}
|
||||||
$this->elementEnd('Image');
|
$this->elementEnd('Image');
|
||||||
$this->elementEnd('img');
|
$this->elementEnd('img');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// No avatar for this user!
|
||||||
}
|
}
|
||||||
|
|
||||||
$person = $this->showMicrobloggingAccount($this->profile,
|
$person = $this->showMicrobloggingAccount($this->profile,
|
||||||
|
@ -100,14 +100,8 @@ class UserrssAction extends Rss10Action
|
|||||||
|
|
||||||
function getImage()
|
function getImage()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$profile = $this->user->getProfile();
|
||||||
$profile = $user->getProfile();
|
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
try {
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
return $avatar->url;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// override parent to add X-SUP-ID URL
|
// override parent to add X-SUP-ID URL
|
||||||
|
@ -92,7 +92,7 @@ class Avatar extends Managed_DataObject
|
|||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function hasOriginal($profile) {
|
public static function hasOriginal(Profile $profile) {
|
||||||
try {
|
try {
|
||||||
$avatar = Avatar::getOriginal($profile);
|
$avatar = Avatar::getOriginal($profile);
|
||||||
} catch (NoResultException $e) {
|
} catch (NoResultException $e) {
|
||||||
|
@ -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)
|
function setOriginal($filename)
|
||||||
{
|
{
|
||||||
$imagefile = new ImageFile($this->id, Avatar::path($filename));
|
$imagefile = new ImageFile($this->id, Avatar::path($filename));
|
||||||
|
@ -722,17 +722,16 @@ class ActivityObject
|
|||||||
if ($this->type == ActivityObject::PERSON
|
if ($this->type == ActivityObject::PERSON
|
||||||
|| $this->type == ActivityObject::GROUP) {
|
|| $this->type == ActivityObject::GROUP) {
|
||||||
|
|
||||||
foreach ($this->avatarLinks as $avatar) {
|
foreach ($this->avatarLinks as $alink) {
|
||||||
$xo->element(
|
$xo->element('link',
|
||||||
'link', array(
|
array(
|
||||||
'rel' => 'avatar',
|
'rel' => 'avatar',
|
||||||
'type' => $avatar->type,
|
'type' => $alink->type,
|
||||||
'media:width' => $avatar->width,
|
'media:width' => $alink->width,
|
||||||
'media:height' => $avatar->height,
|
'media:height' => $alink->height,
|
||||||
'href' => $avatar->url
|
'href' => $alink->url,
|
||||||
),
|
),
|
||||||
null
|
null);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user