Skip to content

Commit a2b3fb9

Browse files
committed
ACP2E-2970: Old media gallery fails to render images when a 0-byte image is placed in the directory
1 parent be7b88d commit a2b3fb9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,22 @@ public function getFilesCollection($path, $type = null)
423423
}
424424

425425
try {
426-
$size = getimagesizefromstring(
427-
$driver->fileGetContents($item->getFilename())
428-
);
429-
430-
if (is_array($size)) {
431-
$item->setWidth($size[0]);
432-
$item->setHeight($size[1]);
426+
if ($item->getSize() > 0) {
427+
$size = getimagesizefromstring(
428+
$driver->fileGetContents($item->getFilename())
429+
);
430+
431+
if (is_array($size)) {
432+
$item->setWidth($size[0]);
433+
$item->setHeight($size[1]);
434+
}
435+
} else {
436+
$this->logger->notice(
437+
sprintf(
438+
"The image file %s cannot be processed by the Gallery because it has an invalid size.",
439+
$item->getFilename()
440+
)
441+
);
433442
}
434443
} catch (\Error $e) {
435444
$this->logger->notice(sprintf("GetImageSize caused error: %s", $e->getMessage()));

0 commit comments

Comments
 (0)