use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
+use Friendica\Model\Contact;
use Friendica\Module;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
function common_content(App $a)
'url' => Model\Contact::magicLink($common_friend['url']),
'itemurl' => ($contact_details['addr'] ?? '') ?: $common_friend['url'],
'name' => $contact_details['name'],
- 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact_details),
'img_hover' => $contact_details['name'],
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
-use Friendica\Util\Proxy as ProxyUtils;
/**
* Controller for /match.
'tags' => $contact_details['keywords'] ?? '',
'about' => $contact_details['about'] ?? '',
'account_type' => Contact::getAccountType($contact_details),
- 'thumb' => ProxyUtils::proxifyUrl($profile->photo, false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact_details, $profile->photo),
'conntxt' => DI::l10n()->t('Connect'),
'connlnk' => $connlnk,
'img_hover' => $profile->tags,
*/
use Friendica\App;
-use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
function network_init(App $a)
'id' => 'network',
'name' => $contact['name'],
'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'],
- 'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact),
'details' => $contact['location'],
];
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\XML;
/**
if (DBA::isResult($notifs)) {
foreach ($notifs as $notif) {
$contact = Contact::getByURL($notif['url'], false, ['micro']);
- if (isset($contact['micro'])) {
- $notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO);
- } else {
- $notif['photo'] = ProxyUtils::proxifyUrl($notif['photo'], false, ProxyUtils::SIZE_MICRO);
- }
+ $notif['photo'] = Contact::getMicro($contact, $notif['photo']);
$local_time = DateTimeFormat::local($notif['date']);
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
use Friendica\Util\Network;
+use Friendica\Util\Proxy;
use Friendica\Util\Strings;
/**
self::updateAvatar($cid, $contact['avatar'], true);
}
+ /**
+ * Return the photo path for a given contact array in the given size
+ *
+ * @param array $contact contact array
+ * @param string $field Fieldname of the photo in the contact array
+ * @param string $default Default path when no picture had been found
+ * @param string $size Size of the avatar picture
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @return string photo path
+ */
+ private static function getAvatarPath(array $contact, string $field, string $default, string $size, string $avatar)
+ {
+ if (!empty($contact)) {
+ $contact = self::checkAvatarCacheByArray($contact);
+ if (!empty($contact[$field])) {
+ $avatar = $contact[$field];
+ }
+ }
+
+ if (empty($avatar)) {
+ return $default;
+ }
+
+ if (Proxy::isLocalImage($avatar)) {
+ return $avatar;
+ } else {
+ return Proxy::proxifyUrl($avatar, false, $size);
+ }
+ }
+
+ /**
+ * Return the photo path for a given contact array
+ *
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @return string photo path
+ */
+ public static function getPhoto(array $contact, string $avatar = '')
+ {
+ return self::getAvatarPath($contact, 'photo', DI::baseUrl() . '/images/person-300.jpg', Proxy::SIZE_SMALL, $avatar);
+ }
+
+ /**
+ * Return the photo path (thumb size) for a given contact array
+ *
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @return string photo path
+ */
+ public static function getThumb(array $contact, string $avatar = '')
+ {
+ return self::getAvatarPath($contact, 'thumb', DI::baseUrl() . '/images/person-80.jpg', Proxy::SIZE_THUMB, $avatar);
+ }
+
+ /**
+ * Return the photo path (micro size) for a given contact array
+ *
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @return string photo path
+ */
+ public static function getMicro(array $contact, string $avatar = '')
+ {
+ return self::getAvatarPath($contact, 'micro', DI::baseUrl() . '/images/person-48.jpg', Proxy::SIZE_MICRO, $avatar);
+ }
+
/**
* Check the given contact array for avatar cache fields
*
* @param array $contact
* @return array contact array with avatar cache fields
*/
- public static function checkAvatarCacheByArray(array $contact)
+ private static function checkAvatarCacheByArray(array $contact)
{
$update = false;
$contact_fields = [];
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
-use Friendica\Util\Proxy as ProxyUtils;
/**
* This module shows all public friends of the selected contact
'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
'itemurl' => ($contactDetails['addr'] ?? '') ?: $friend['url'],
'name' => $contactDetails['name'],
- 'thumb' => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Model\Contact::getThumb($contactDetails),
'img_hover' => $contactDetails['name'],
'details' => $contactDetails['location'],
'tags' => $contactDetails['keywords'],
if ($contact['network'] == Protocol::PHANTOM) {
$contact = false;
}
-
- $contact = ModelContact::checkAvatarCacheByArray($contact);
}
if (DBA::isResult($contact)) {
$vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
'$name' => $contact['name'],
- '$photo' => $contact['photo'],
+ '$photo' => Model\Contact::getPhoto($contact),
'$url' => Model\Contact::magicLinkByContact($contact, $contact['url']),
'$addr' => $contact['addr'] ?? '',
'$network_link' => $network_link,
'$notify' => ['notify', DI::l10n()->t('Notification for new posts'), ($contact['notify_new_posts'] == 1), DI::l10n()->t('Send a notification of every new post of this contact')],
'$fetch_further_information' => $fetch_further_information,
'$ffi_keyword_denylist' => ['ffi_keyword_denylist', DI::l10n()->t('Keyword Deny List'), $contact['ffi_keyword_denylist'], DI::l10n()->t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')],
- '$photo' => $contact['photo'],
+ '$photo' => Model\Contact::getPhoto($contact),
'$name' => $contact['name'],
'$dir_icon' => $dir_icon,
'$sparkle' => $sparkle,
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\GContact;
use Friendica\Network\HTTPException;
use Friendica\Util\Strings;
-use Friendica\Util\Proxy;
/**
* Asynchronous HTML fragment provider for frio contact hovercards
'name' => $contact['name'],
'nick' => $contact['nick'],
'addr' => $contact['addr'] ?: $contact['url'],
- 'thumb' => Proxy::proxifyUrl($contact['thumb'], false, Proxy::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact),
'url' => Contact::magicLink($contact['url']),
'nurl' => $contact['nurl'],
'location' => $contact['location'],
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Network\HTTPException;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
/**
'id' => $contact['id'],
'url' => Contact::magicLink($profile_link),
'itemurl' => $itemurl,
- 'thumb' => ProxyUtils::proxifyUrl($contact[$photo_size], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact),
'img_hover' => $contact['name'],
'name' => $contact['name'],
'details' => $details,
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Module\BaseProfile;
-use Friendica\Util\Proxy as ProxyUtils;
class Contacts extends BaseProfile
{
'id' => $contact['id'],
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
'photo_menu' => Contact::photoMenu($contact),
- 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
+ 'thumb' => Contact::getThumb($contact_details),
'name' => substr($contact_details['name'], 0, 20),
'username' => $contact_details['name'],
'details' => $contact_details['location'],
foreach ($r as $g) {
$entry = [
'type' => 'c',
- 'photo' => ProxyUtils::proxifyUrl($g['micro'], false, ProxyUtils::SIZE_MICRO),
+ 'photo' => Contact::getMicro($g),
'name' => htmlspecialchars($g['name']),
'id' => intval($g['id']),
'network' => $g['network'],
if (count($contact) > 0) {
$unknown_contacts[] = [
'type' => 'c',
- 'photo' => ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO),
+ 'photo' => Contact::getMicro($contact),
'name' => htmlspecialchars($contact['name']),
'id' => intval($contact['cid']),
'network' => $contact['network'],
* @return boolean
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- private static function isLocalImage($url)
+ public static function isLocalImage($url)
{
if (substr($url, 0, 1) == '/') {
return true;