use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Core\Storage\Exception\StorageException;
use Friendica\Core\Storage\Type\SystemResource;
-use Friendica\Network\HTTPClient\Client\HttpClient;
-use Friendica\Network\HTTPClient\Client\HttpClientOptions;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_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();
}
$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));
}
/**
{
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_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();