X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FImages.php;h=bf84ee6c22552bad74d3db1eb83272a5bc52f0d3;hb=0cafa871f1611f283a0f22ec3bb4e3c610028afc;hp=f39b0db00dc235a643475159e562724bc4c0c0b6;hpb=afb882048efa8c4b2914a6b054b129dee57061ef;p=friendica.git diff --git a/src/Util/Images.php b/src/Util/Images.php index f39b0db00d..bf84ee6c22 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -1,6 +1,6 @@ fetch($url, true, 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::httpRequest()->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 []; }