1
0
Fork 0

Replaced check with hardwired path

This commit is contained in:
Michael 2022-05-09 04:26:00 +00:00
commit e3692c0105
4 changed files with 23 additions and 9 deletions

View file

@ -1611,17 +1611,17 @@ class Contact
if (DI::config()->get('system', 'avatar_cache')) {
switch ($size) {
case Proxy::SIZE_MICRO:
if (self::isAvatarFile($contact['micro'])) {
if (!empty($contact['micro']) && !Photo::isPhotoURI($contact['micro'])) {
return $contact['micro'];
}
break;
case Proxy::SIZE_THUMB:
if (self::isAvatarFile($contact['thumb'])) {
if (!empty($contact['thumb']) && !Photo::isPhotoURI($contact['thumb'])) {
return $contact['thumb'];
}
break;
case Proxy::SIZE_SMALL:
if (self::isAvatarFile($contact['photo'])) {
if (!empty($contact['photo']) && !Photo::isPhotoURI($contact['photo'])) {
return $contact['photo'];
}
break;
@ -2187,7 +2187,7 @@ class Contact
* @param string $avatar
* @return boolean
*/
public static function isAvatarFile(string $avatar): bool
private static function isAvatarFile(string $avatar): bool
{
return !empty(self::getAvatarFile($avatar));
}

View file

@ -710,6 +710,18 @@ class Photo
return $image_uri;
}
/**
* Checks if the given URL is a local photo.
* Since it is meant for time critical occasions, the check is done without any database requests.
*
* @param string $url
* @return boolean
*/
public static function isPhotoURI(string $url): bool
{
return !empty(self::ridFromURI($url));
}
/**
* Changes photo permissions that had been embedded in a post
*