use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
'name' => $profile_name,
'sparkle' => $sparkle,
'lock' => false,
- 'thumb' => DI::baseUrl()->remove($item['author-avatar']),
+ 'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)),
'title' => $title,
'body_html' => $body_html,
'tags' => $tags['tags'],
use Friendica\Model\Verb;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Proxy;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
usort($notifications, $sort_function);
array_walk($notifications, function (&$notification) {
- if (empty($notification['photo'])) {
- $contact = Contact::getByURL($notification['url'], false, ['micro', 'id', 'avatar']);
- $notification['photo'] = Contact::getMicro($contact, $notification['photo']);
- }
-
+ $notification['photo'] = Contact::getAvatarUrlForUrl($notification['url'], local_user(), Proxy::SIZE_MICRO);
$notification['timestamp'] = DateTimeFormat::local($notification['date']);
- $notification['date'] = Temporal::getRelativeDate($notification['date']);
+ $notification['date'] = Temporal::getRelativeDate($notification['date']);
});
}
{
if (!empty($contact)) {
$contact = self::checkAvatarCacheByArray($contact, $no_update);
- if (!empty($contact[$field])) {
- return $contact[$field];
- } elseif (!empty($contact['id'])) {
+ if (!empty($contact['id'])) {
return self::getAvatarUrlForId($contact['id'], $size, $contact['updated'] ?? '');
+ } elseif (!empty($contact[$field])) {
+ return $contact[$field];
} elseif (!empty($contact['avatar'])) {
$avatar = $contact['avatar'];
}
$condition = ["`nurl` = ? AND ((`uid` = ? AND `network` IN (?, ?)) OR `uid` = ?)",
Strings::normaliseLink($url), $uid, Protocol::FEED, Protocol::MAIL, 0];
$contact = self::selectFirst(['id', 'updated'], $condition);
- return self::getAvatarUrlForId($contact['id'] ?? 0, $size, $contact['updated']);
+ return self::getAvatarUrlForId($contact['id'] ?? 0, $size, $contact['updated'] ?? '');
}
/**
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $keywords);
$keywords = explode(',', $keywords);
- $contactPhoto = DBA::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $profile['uid']]);
-
$json_info['fn'] = $profile['name'];
- $json_info['photo'] = $contactPhoto["photo"];
+ $json_info['photo'] = Contact::getAvatarUrlForUrl($profile['url'], $profile['uid']);
$json_info['tags'] = $keywords;
$json_info['language'] = $profile['language'];
$contact = Contact::getByURL($contact['url'], false, ['avatar', 'photo', 'xmpp', 'addr']);
}
if (!empty($contact['photo'])) {
+ // Fetch photo directly
+ $resourceid = MPhoto::ridFromURI($contact['photo']);
+ if (!empty($resourceid)) {
+ $photo = MPhoto::selectFirst([], ['resource-id' => $resourceid], ['order' => ['scale']]);
+ if (!empty($photo)) {
+ return $photo;
+ }
+ }
$url = $contact['photo'];
} elseif (!empty($contact['avatar'])) {
$url = $contact['avatar'];
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
'profile_url' => $profile_link,
'name' => $profile_name,
'item_photo_menu_html' => item_photo_menu($item),
- 'thumb' => DI::baseUrl()->remove($item['author-avatar']),
+ 'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)),
'osparkle' => $osparkle,
'sparkle' => $sparkle,
'title' => $title,
return [];
}
- $fields = ['name', 'url', 'location', 'about', 'avatar', 'photo'];
+ $fields = ['id', 'name', 'url', 'location', 'about', 'avatar', 'photo', 'updated'];
$contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($contact)) {
return [];
'owner' => $contact['url'],
'publicKeyPem' => $user['pubkey']];
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
- $data['icon'] = ['type' => 'Image', 'url' => $contact['photo']];
+ $data['icon'] = ['type' => 'Image', 'url' => Contact::getAvatarUrlForId($contact['id'], '', $contact['updated'])];
$resourceid = Photo::ridFromURI($contact['photo']);
if (!empty($resourceid)) {
}
if (!empty($contact['header'])) {
- $data['image'] = ['type' => 'Image', 'url' => $contact['header']];
+ $data['image'] = ['type' => 'Image', 'url' => Contact::getHeaderUrlForId($contact['id'], '', $contact['updated'])];
$resourceid = Photo::ridFromURI($contact['header']);
if (!empty($resourceid)) {