ACSD-58131: Old media gallery fails to load images due to 0-byte image file
The ACSD-58131 patch fixes the issue where the old media gallery fails to render images when a 0-byte image is present in the directory. This patch is available when the Quality Patches Tool (QPT) 1.1.68 is installed. The patch ID is ACSD-58131. Please note that this issue is scheduled to be fixed in ÃÛ¶¹ÊÓÆµ Commerce 2.5.0.
Affected products and versions
The patch is created for ÃÛ¶¹ÊÓÆµ Commerce version:
- ÃÛ¶¹ÊÓÆµ Commerce (all deployment methods) 2.4.6-p4
Compatible with ÃÛ¶¹ÊÓÆµ Commerce versions:
- ÃÛ¶¹ÊÓÆµ Commerce (all deployment methods) 2.4.4 - 2.4.7-p6
magento/quality-patches
package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.Issue
When a 0-byte image is placed in the media gallery directory, the old media gallery fails to render any images. The updated system now skips invalid 0-byte files, displays valid images as expected, and logs a warning for each invalid file.
[2024-05-02T14:00:39.616459+00:00] report.WARNING: The image empty2.jpg is invalid and cannot be displayed in the gallery. [] []
Steps to reproduce:
-
Go to Stores > Configuration > Advanced > System > Media Gallery.
-
Set Enable Old Media Gallery to Yes.
-
Place a few images in the
pub/media/wysiwyg
directory. -
Create a 0-byte image in the same directory using
touch pub/media/wysiwyg/empty_image.png
. -
Add an image from the
wysiwyg
directory via Page Builder under any content (for example, a CMS Block):- Create a new block. Go to Content > Elements > Blocks and click Add New Block.
- Edit the content section using Page Builder.
- Under Layout, drag a new Row to the stage.
- Expand Media and drag an Image placeholder into the row.
- Click Select from Gallery.
- Select the
wysiwyg
directory if it’s not selected by default.
Expected results:
The media gallery remains functional even if a 0-byte image (or any other file) exists.
Actual results:
The media gallery fails to load any images from the wysiwyg
directory due to a critical error logged in var/log/system.log
:
[2024-03-22T05:00:55.100934+00:00] report.CRITICAL: Exception: Notice: getimagesizefromstring(): Error reading from ! in /app/project/vendor/magento/module-cms/Model/Wysiwyg/Images/Storage.php on line 426 in /app/project/vendor/magento/framework/App/ErrorHandler.php:62
Apply the patch
To apply individual patches, use the following links depending on your deployment method:
- ÃÛ¶¹ÊÓÆµ Commerce or Magento Open Source on-premises: Quality Patches Tool > Usage in the Quality Patches Tool guide.
- ÃÛ¶¹ÊÓÆµ Commerce on cloud infrastructure: Upgrades and Patches > Apply Patches in the Commerce on Cloud Infrastructure guide.
Related reading
To learn more about Quality Patches Tool, refer to:
- Quality Patches Tool: A self-service tool for quality patches in the Tools guide.