From 0b8c9a1c2484e2eb3d925bca83a9f63556499f46 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 10 Feb 2020 00:00:00 +0100 Subject: [PATCH] Fixed image size of a remote file. --- src/Mvc/Controller/Plugin/ImageSize.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Mvc/Controller/Plugin/ImageSize.php b/src/Mvc/Controller/Plugin/ImageSize.php index d944619..0c08aa8 100644 --- a/src/Mvc/Controller/Plugin/ImageSize.php +++ b/src/Mvc/Controller/Plugin/ImageSize.php @@ -90,14 +90,18 @@ protected function getWidthAndHeight($filepath) $tempFile = $this->tempFileFactory->build(); $tempPath = $tempFile->getTempPath(); $tempFile->delete(); - $result = file_put_contents($tempPath, $filepath); - if ($result !== false) { - $result = getimagesize($tempPath); + $handle = @fopen($filepath, 'rb'); + if ($handle) { + $result = file_put_contents($tempPath, $handle); + @fclose($handle); if ($result) { - list($width, $height) = $result; + $result = getimagesize($tempPath); + if ($result) { + list($width, $height) = $result; + } } + unlink($tempPath); } - unlink($tempPath); } // A normal path. elseif (file_exists($filepath)) {