diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 9d609786e..2afe91d13 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -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, diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 6f58cb7f5..c67520b55 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -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']); } diff --git a/view/templates/profile/vcard.tpl b/view/templates/profile/vcard.tpl index bc39dcce4..fed6fb251 100644 --- a/view/templates/profile/vcard.tpl +++ b/view/templates/profile/vcard.tpl @@ -5,11 +5,8 @@ {{if $profile.addr}}
{{$profile.addr}}
{{/if}} - {{if $profile.picdate}} -
{{$profile.name}}
- {{else}} -
{{$profile.name}}
- {{/if}} +
{{$profile.name}}
+ {{if $account_type}}
{{$account_type}}
{{/if}} {{if $profile.network_link}}
{{$network}}
{{$profile.network_link nofilter}}
{{/if}} {{if $location}} diff --git a/view/theme/duepuntozero/templates/profile/vcard.tpl b/view/theme/duepuntozero/templates/profile/vcard.tpl index cba78da6a..c6af35ba0 100644 --- a/view/theme/duepuntozero/templates/profile/vcard.tpl +++ b/view/theme/duepuntozero/templates/profile/vcard.tpl @@ -5,7 +5,7 @@ {{if $profile.addr}}
{{$profile.addr}}
{{/if}} -
{{$profile.name}}
+
{{$profile.name}}
{{if $account_type}}
{{$account_type}}
{{/if}} diff --git a/view/theme/frio/templates/profile/vcard.tpl b/view/theme/frio/templates/profile/vcard.tpl index ba66882e2..b91c14168 100644 --- a/view/theme/frio/templates/profile/vcard.tpl +++ b/view/theme/frio/templates/profile/vcard.tpl @@ -1,12 +1,7 @@
- {{if $profile.picdate}} - {{$profile.name}} - {{else}} {{$profile.name}} - {{/if}} -
{{if $profile.edit}}
@@ -21,11 +16,7 @@