]> git.mxchange.org Git - friendica.git/commitdiff
Issue 11034: Use the profile photo for local users
authorMichael <heluecht@pirati.ca>
Tue, 1 Feb 2022 19:12:33 +0000 (19:12 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 1 Feb 2022 19:12:33 +0000 (19:12 +0000)
src/Module/Photo.php
view/templates/profile/vcard.tpl
view/theme/duepuntozero/templates/profile/vcard.tpl
view/theme/frio/templates/profile/vcard.tpl
view/theme/quattro/templates/profile/vcard.tpl
view/theme/vier/templates/profile/vcard.tpl

index 6f58cb7f57caa8f741bc07078969f45511c08d38..c67520b554d92879e21e37e087388380f4a9ff6c 100644 (file)
@@ -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']);
                                }
index bc39dcce4b12ff9e62e759cbc3fe86d6ac1a0c88..fed6fb251a541229f62d26e4c6a32424743092da 100644 (file)
@@ -5,11 +5,8 @@
        
        {{if $profile.addr}}<div class="p-addr">{{$profile.addr}}</div>{{/if}}
        
-       {{if $profile.picdate}}
-               <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></a></div>
-       {{else}}
-               <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div>
-       {{/if}}
+       <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div>
+
        {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
        {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}
        {{if $location}}
index cba78da6af932a490c36e04d9a0641775b66f59f..c6af35ba0069c675ff24199954cfeb1b0d91ba9c 100644 (file)
@@ -5,7 +5,7 @@
        
        {{if $profile.addr}}<div class="p-addr">{{$profile.addr}}</div>{{/if}}
        
-       <div id="profile-photo-wrapper"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></div>
+       <div id="profile-photo-wrapper"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}"></div>
 
        {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
 
index ba66882e2e012a2d1d2b20f9f0d5e98d379ca772..b91c14168b3441dfac309abced4f0df0d739a160 100644 (file)
@@ -1,12 +1,7 @@
 <div class="vcard h-card widget">
 
        <div id="profile-photo-wrapper">
-               {{if $profile.picdate}}
-               <a href="{{$profile.url}}"><img class="photo u-photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}" /></a>
-               {{else}}
                <a href="{{$profile.url}}"><img class="photo u-photo" src="{{$profile.photo}}" alt="{{$profile.name}}" /></a>
-               {{/if}}
-
                <div class="tool visible-lg visible-md">
                        {{if $profile.edit}}
                        <div class="action">
        <div id="vcard-short-info-wrapper" style="display: none;">
                <div id="vcard-short-info" class="media" style="display: none">
                        <div id="vcard-short-photo-wrapper" class="pull-left">
-                               {{if $profile.picdate}}
-                               <img class="media-object" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></a>
-                               {{else}}
                                <img class="media-object" src="{{$profile.photo}}" alt="{{$profile.name}}"></a>
-                               {{/if}}
                        </div>
 
                        <div id="vcard-short-desc" class="media-body">
index dc5b0c7d1f2674f204c12a62fd162e93cbce172a..e66334dc214bd2580fd4be2f273e82a6e67e4803 100644 (file)
@@ -17,7 +17,7 @@
 
        {{if $profile.addr}}<div class="p-addr">{{$profile.addr}}</div>{{/if}}
 
-       <div id="profile-photo-wrapper"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}" /></div>
+       <div id="profile-photo-wrapper"><img class="photo u-photo" width="175" height="175" src="{{$profile.photo}}" alt="{{$profile.name}}" /></div>
 
        {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
 
index c15e7940d3d2567fc948a1654c38b3c4e79492bc..01e75580dffd8cba03c3e6954e346bb931734926 100644 (file)
 
        {{if $profile.addr}}<div class="p-addr">{{$profile.addr}}</div>{{/if}}
 
-       {{if $profile.picdate}}
-               <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.name}}"></a></div>
-       {{else}}
-               <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div>
-       {{/if}}
+       <div id="profile-photo-wrapper"><a href="{{$profile.url}}"><img class="photo u-photo" src="{{$profile.photo}}" alt="{{$profile.name}}"></a></div>
 
        {{if $account_type}}<div class="account-type">{{$account_type}}</div>{{/if}}
        {{if $profile.network_link}}<dl class="network"><dt class="network-label">{{$network}}</dt><dd class="x-network">{{$profile.network_link nofilter}}</dd></dl>{{/if}}