Using a constant value for the default avatar

This commit is contained in:
Michael 2020-08-18 20:30:24 +00:00
parent 76bcf27130
commit d9fc0ae0ea
8 changed files with 28 additions and 21 deletions

View File

@ -481,7 +481,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
if (DBA::isResult($contact)) {
$photo = $contact['photo'];
} else {
$photo = DI::baseUrl() . '/images/person-300.jpg';
$photo = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
}
Contact::updateAvatar($dfrn_record, $photo);

View File

@ -27,6 +27,7 @@ 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\Model\User;
@ -183,7 +184,7 @@ class Nav
// user info
$contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = [
'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : 'images/person-48.jpg'),
'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : Contact::DEFAULT_AVATAR_MICRO),
'name' => $a->user['username'],
];
} else {

View File

@ -132,7 +132,7 @@ class Introduction extends BaseFactory
'madeby_zrl' => Contact::magicLink($notification['url']),
'madeby_addr' => $notification['addr'],
'contact_id' => $notification['contact-id'],
'photo' => (!empty($notification['fphoto']) ? Proxy::proxifyUrl($notification['fphoto'], false, Proxy::SIZE_SMALL) : "images/person-300.jpg"),
'photo' => (!empty($notification['fphoto']) ? Proxy::proxifyUrl($notification['fphoto'], false, Proxy::SIZE_SMALL) : Contact::DEFAULT_AVATAR_PHOTO),
'name' => $notification['fname'],
'url' => $notification['furl'],
'zrl' => Contact::magicLink($notification['furl']),

View File

@ -51,6 +51,10 @@ use Friendica\Util\Strings;
*/
class Contact
{
const DEFAULT_AVATAR_PHOTO = '/images/person-300.jpg';
const DEFAULT_AVATAR_THUMB = '/images/person-80.jpg';
const DEFAULT_AVATAR_MICRO = '/images/person-48.jpg';
/**
* @deprecated since version 2019.03
* @see User::PAGE_FLAGS_NORMAL
@ -644,9 +648,9 @@ class Contact
$fields['micro'] = $prefix . '6' . $suffix;
} else {
// We hadn't found a photo entry, so we use the default avatar
$fields['photo'] = DI::baseUrl() . '/images/person-300.jpg';
$fields['thumb'] = DI::baseUrl() . '/images/person-80.jpg';
$fields['micro'] = DI::baseUrl() . '/images/person-48.jpg';
$fields['photo'] = DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO;
$fields['thumb'] = DI::baseUrl() . self::DEFAULT_AVATAR_THUMB;
$fields['micro'] = DI::baseUrl() . self::DEFAULT_AVATAR_MICRO;
}
$fields['avatar'] = DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix;
@ -1467,7 +1471,7 @@ class Contact
*/
public static function getPhoto(array $contact, string $avatar = '')
{
return self::getAvatarPath($contact, 'photo', DI::baseUrl() . '/images/person-300.jpg', Proxy::SIZE_SMALL, $avatar);
return self::getAvatarPath($contact, 'photo', DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO, Proxy::SIZE_SMALL, $avatar);
}
/**
@ -1479,7 +1483,7 @@ class Contact
*/
public static function getThumb(array $contact, string $avatar = '')
{
return self::getAvatarPath($contact, 'thumb', DI::baseUrl() . '/images/person-80.jpg', Proxy::SIZE_THUMB, $avatar);
return self::getAvatarPath($contact, 'thumb', DI::baseUrl() . self::DEFAULT_AVATAR_THUMB, Proxy::SIZE_THUMB, $avatar);
}
/**
@ -1491,7 +1495,7 @@ class Contact
*/
public static function getMicro(array $contact, string $avatar = '')
{
return self::getAvatarPath($contact, 'micro', DI::baseUrl() . '/images/person-48.jpg', Proxy::SIZE_MICRO, $avatar);
return self::getAvatarPath($contact, 'micro', DI::baseUrl() . self::DEFAULT_AVATAR_MICRO, Proxy::SIZE_MICRO, $avatar);
}
/**
@ -1530,13 +1534,13 @@ class Contact
/// add the default avatars if the fields aren't filled
if (isset($contact['photo']) && empty($contact['photo'])) {
$contact['photo'] = DI::baseUrl() . '/images/person-300.jpg';
$contact['photo'] = DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO;
}
if (isset($contact['thumb']) && empty($contact['thumb'])) {
$contact['thumb'] = DI::baseUrl() . '/images/person-80.jpg';
$contact['thumb'] = DI::baseUrl() . self::DEFAULT_AVATAR_THUMB;
}
if (isset($contact['micro']) && empty($contact['micro'])) {
$contact['micro'] = DI::baseUrl() . '/images/person-48.jpg';
$contact['micro'] = DI::baseUrl() . self::DEFAULT_AVATAR_MICRO;
}
return $contact;

View File

@ -492,9 +492,9 @@ class Photo
}
if ($photo_failure) {
$image_url = DI::baseUrl() . "/images/person-300.jpg";
$thumb = DI::baseUrl() . "/images/person-80.jpg";
$micro = DI::baseUrl() . "/images/person-48.jpg";
$image_url = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
$thumb = DI::baseUrl() . Contact::DEFAULT_AVATAR_THUMB;
$micro = DI::baseUrl() . Contact::DEFAULT_AVATAR_MICRO;
}
return [$image_url, $thumb, $micro];

View File

@ -23,8 +23,8 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Photo as MPhoto;
/**
@ -139,16 +139,16 @@ class Photo extends BaseModule
case "profile":
case "custom":
$scale = 4;
$default = "images/person-300.jpg";
$default = Contact::DEFAULT_AVATAR_PHOTO;
break;
case "micro":
$scale = 6;
$default = "images/person-48.jpg";
$default = Contact::DEFAULT_AVATAR_MICRO;
break;
case "avatar":
default:
$scale = 5;
$default = "images/person-80.jpg";
$default = Contact::DEFAULT_AVATAR_THUMB;
}
$photo = MPhoto::selectFirst([], ["scale" => $scale, "uid" => $uid, "profile" => 1]);

View File

@ -29,6 +29,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Profile;
use Friendica\Model\User;
@ -369,7 +370,7 @@ class Probe
}
if (empty($data['photo'])) {
$data['photo'] = DI::baseUrl() . '/images/person-300.jpg';
$data['photo'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
}
if (empty($data['name'])) {

View File

@ -24,6 +24,7 @@ namespace Friendica\Util;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Contact;
class Network
{
@ -235,7 +236,7 @@ class Network
Hook::callAll('avatar_lookup', $avatar);
if (! $avatar['success']) {
$avatar['url'] = DI::baseUrl() . '/images/person-300.jpg';
$avatar['url'] = DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO;
}
Logger::log('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], Logger::DEBUG);