X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FImages.php;h=8a810510f0489916363b98e1d397e430b602a9e0;hb=fca93793480839660870e899bea88f3637859fff;hp=a65f9a1a8b16fa24ed022a74ea1711d4aee0730a;hpb=53e38b03130ea798bba44db44ccb7f331dc4b91d;p=friendica.git diff --git a/src/Util/Images.php b/src/Util/Images.php index a65f9a1a8b..8a810510f0 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -22,8 +22,8 @@ namespace Friendica\Util; use Friendica\Core\Logger; -use Friendica\Core\System; use Friendica\DI; +use Friendica\Model\Photo; /** * Image utilities @@ -184,7 +184,17 @@ class Images return $data; } - $img_str = DI::httpRequest()->fetch($url, 4); + if (Network::isLocalLink($url) && ($data = Photo::getResourceData($url))) { + $photo = Photo::selectFirst([], ['resource-id' => $data['guid'], 'scale' => $data['scale']]); + if (!empty($photo)) { + $img_str = Photo::getImageDataForPhoto($photo); + } + // @todo Possibly add a check for locally stored files + } + + if (empty($img_str)) { + $img_str = DI::httpClient()->fetch($url, 4); + } if (!$img_str) { return []; @@ -193,18 +203,7 @@ class Images $filesize = strlen($img_str); try { - if (function_exists("getimagesizefromstring")) { - $data = @getimagesizefromstring($img_str); - } else { - $tempfile = tempnam(get_temppath(), "cache"); - - $stamp1 = microtime(true); - file_put_contents($tempfile, $img_str); - DI::profiler()->saveTimestamp($stamp1, "file"); - - $data = getimagesize($tempfile); - unlink($tempfile); - } + $data = @getimagesizefromstring($img_str); } catch (\Exception $e) { return []; }