Skip to content

Magento 2.3 images cache generation generates wrong hash for some images with a custom theme that has the keep_frame var set to 0 #19710

@carolineboivin

Description

@carolineboivin

Summary (*)

I just upgrade my Magento 2 project from 2.2.6 to 2.3. After the upgrade, some images in the catalog are showing placeholders instead of the images. I have regenerated the images cache with the catalog:images:resize but some images are still missing (swatch images in category pages and image thumbnail in category pages).

After some investigation, it seems that is it a problem with the hash used for the image cache directory. When generating the images cache in the CLI, all images have in their misc params used to build the hash a value of "keep_frame" => 1, although in the view.xml file of my custom theme, the param "product_image_white_borders" is set to 0. When generating the image path for the catalog pages, the keep frame param is 0.

My investigation led me to the ParamsBuilder class (module-catalog/Model/Product/Image/ParamsBuilder) that uses its viewConfig property to get the value of the var "product_image_white_borders" in the "hasDefaultFrame" function. Seemingly, when running the CLI command, the view config that is injected in the ParamsBuilder is not the same that is used by the ImageResize command, and it has a wrong "product_image_white_borders" value of 1. It seems that it does not use the theme that the ImageResize command is currently processing, and its scope is global.

Environment

Magento 2.3 Open Source with custom frontend theme

Examples (*)

Assign images to products in the catalog.
Set the value of the variable "product_image_white_borders" to 0 in your custom theme view.xml file.
Regenerate product images cache with the CLI command catalog:images:resize.

Proposed solution

The product thumbnail in category pages should appear but instead the placeholder image is shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CDIssue recommended for the contribution dayComponent: ThemeIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.help wanted

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions