Skip to content

Commit cf6f6af

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public function getFilesCollection($path, $type = null)
415415
$mimeType = $itemStats['mimetype'] ?? $this->mime->getMimeType($item->getFilename());
416416
$item->setMimeType($mimeType);
417417

418-
if ($this->isImage($item->getBasename())) {
418+
if ($this->isImage($item->getBasename()) && $item->getSize() > 0) {
419419
$thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
420420
// generate thumbnail "on the fly" if it does not exists
421421
if (!$thumbUrl) {
@@ -435,6 +435,12 @@ public function getFilesCollection($path, $type = null)
435435
$this->logger->notice(sprintf("GetImageSize caused error: %s", $e->getMessage()));
436436
}
437437
} else {
438+
$this->logger->warning(
439+
sprintf(
440+
"The image %s is invalid and cannot be displayed in the gallery.",
441+
$item->getBasename()
442+
)
443+
);
438444
$thumbUrl = $this->_assetRepo->getUrl(self::THUMB_PLACEHOLDER_PATH_SUFFIX);
439445
}
440446

0 commit comments

Comments
 (0)