Skip to content

magento/magento2#35535: Magento 2.4.4 Mini cart item images not showing #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

craig-bartlett
Copy link
Owner

  • Cast resized image dimensions from floats to integers for GD and ImageMagick as imagecopy expects ints

Description (*)

If images have odd dimensions then when they are resized in the image adapters for GD and ImageMagick the resulting dimensions are stored as floats:

$positionX = $this->_imageSrcWidth / 2 - imagesx($watermark) / 2;

These are later passed to PHP's imagecopy function which expects integers and so throws warnings. This results in the offending image size being missed when generating catalog images. Simply casting the results of the resizing lines to ints fixes this.

$positionX = (int) ($this->_imageSrcWidth / 2 - imagesx($watermark) / 2);

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Magento 2.4.4 Mini cart item images not showing magento/magento2#35535

Manual testing scenarios (*)

  1. As mentioned in the issue thread by @benyatesvortex, this can be tested by running the image resize command manually (bin/magento catalog:image:resize). If either the width or height are odd (and the watermark is even), the result will be a float causing imagecopy() to throw a warning and the image to be skipped.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

- Cast resized image dimensions from floats to integers for GD and ImageMagick as imagecopy expects ints
@craig-bartlett craig-bartlett merged commit f402686 into 2.4-develop Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Magento 2.4.4 Mini cart item images not showing
1 participant