Merge pull request #11200 from annando/issue-11034
Issue 11034: Use the profile photo for local users
This commit is contained in:
commit
4ad528a15c
7 changed files with 33 additions and 23 deletions
|
@ -1913,7 +1913,14 @@ class Contact
|
|||
$avatar = self::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
|
||||
}
|
||||
|
||||
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || DI::config()->get('system', 'cache_contact_avatar')) {
|
||||
$cache_avatar = DI::config()->get('system', 'cache_contact_avatar');
|
||||
|
||||
// Local contact avatars don't need to be cached
|
||||
if ($cache_avatar && Network::isLocalLink($contact['url'])) {
|
||||
$cache_avatar = !DBA::exists('contact', ['nurl' => $contact['nurl'], 'self' => true]);
|
||||
}
|
||||
|
||||
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || $cache_avatar) {
|
||||
if ($default_avatar && Proxy::isLocalImage($avatar)) {
|
||||
$fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
|
||||
'photo' => $avatar,
|
||||
|
|
|
@ -265,10 +265,29 @@ class Photo extends BaseModule
|
|||
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype']);
|
||||
case "contact":
|
||||
$contact = Contact::getById($id, ['uid', 'url', 'avatar', 'photo', 'xmpp', 'addr']);
|
||||
$contact = Contact::getById($id, ['uid', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr']);
|
||||
if (empty($contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For local users directly use the photo record that is marked as the profile
|
||||
if (Network::isLocalLink($contact['url'])) {
|
||||
$contact = Contact::selectFirst(['uid', 'url', 'avatar', 'photo', 'xmpp', 'addr'], ['nurl' => $contact['nurl'], 'self' => true]);
|
||||
if (!empty($contact)) {
|
||||
if ($customsize <= Proxy::PIXEL_MICRO) {
|
||||
$scale = 6;
|
||||
} elseif ($customsize <= Proxy::PIXEL_THUMB) {
|
||||
$scale = 5;
|
||||
} else {
|
||||
$scale = 4;
|
||||
}
|
||||
$photo = MPhoto::selectFirst([], ["scale" => $scale, "uid" => $contact['uid'], "profile" => 1]);
|
||||
if (!empty($photo)) {
|
||||
return $photo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
If (($contact['uid'] != 0) && empty($contact['photo']) && empty($contact['avatar'])) {
|
||||
$contact = Contact::getByURL($contact['url'], false, ['avatar', 'photo', 'xmpp', 'addr']);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue