Skip to content

Commit

Permalink
Fixed image size of a remote file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Feb 9, 2020
1 parent c3e761c commit 0b8c9a1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Mvc/Controller/Plugin/ImageSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 0b8c9a1

Please sign in to comment.