X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=d9e6f7cadebb8c54688cce3f531d15d5e025da54;hb=624e4c192c7f837ac0587a50da6e1409081eb519;hp=5701eabdb9686df618ecddba2125e747120c5c8a;hpb=73c3b21665e7e22c4c9908272279d9605282acca;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 5701eabdb9..d9e6f7cade 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -33,7 +33,6 @@ use Friendica\Core\Storage\Exception\ReferenceStorageException; use Friendica\Core\Storage\Exception\StorageException; use Friendica\Core\Storage\Type\SystemResource; use Friendica\Network\HTTPClient\Client\HttpClientAccept; -use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Object\Image; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; @@ -499,7 +498,7 @@ class Photo $filename = basename($image_url); if (!empty($image_url)) { - $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]); + $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE); Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]); $img_str = $ret->getBody(); $type = $ret->getContentType(); @@ -705,10 +704,19 @@ class Photo } $image_uri = substr($image_uri, strrpos($image_uri, '/') + 1); $image_uri = substr($image_uri, 0, strpos($image_uri, '-')); - if (!strlen($image_uri)) { - return ''; - } - return $image_uri; + return trim($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)); } /** @@ -915,7 +923,7 @@ class Photo { $filename = basename($image_url); if (!empty($image_url)) { - $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]); + $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE); Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]); $img_str = $ret->getBody(); $type = $ret->getContentType();