+
+ // 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 (!empty($contact['uid']) && empty($contact['photo']) && empty($contact['avatar'])) {