-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Magento 2.4.4 Mini cart item images not showing #35535
Magento 2.4.4 Mini cart item images not showing #35535
Comments
Hi @khoimm92. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-Dash. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
Hello @khoimm92 , Please refer the below screenshot for the reference; |
@khoimm92, this is just a guess, but could it be that you have a custom theme with a Also: where did you see that error? Was it outputted to a certain log file? Because I don't see it when I quickly test it out ... |
Magento 2.4.4 small_image URL returns the wrong cache hash in products and cart GraphQL for the default store. In other stores, it returns the correct URL. |
Fix for me, maybe help you @khoimm92 |
Dear @khoimm92 , We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this. Thanks. |
Hi, I've recently come across this same issue. It is indeed caused by theme images with an odd dimension and the watermark position set to centre. If using the Gd2 adapter, it uses the following to calculate the position:
If the image size has an odd dimension, this results in a float. These are then passed to imagecopymergeWithAlphaFix on the next line, which passes them to imagecopy. This function expects integers and therefore gives the warning that the OP reported. I think the same is true for the ImageMagick adapter as it handles it in the same way. For what it's worth - when debugging this I didn't see any warnings at all in the system or debug log, only managing to get the output the OP saw by wrapping the call to createWatermarkBasedOnPosition in a try/catch. The only sign I had that something was wrong was several missing folders in media/catalog/product/cache which relate to the sizes that were being silently skipped. Generating the images from the command line also gave no errors/warnings. It's worth noting that I couldn't find anything in the documentation regarding the use of odd dimensions with image sizes. I patched this for our instances (2.4.4) by explicitly casting the resulting positions to integers. It works for us but your results may vary. index af08cb5..2191f34 100644
--- a/vendor/magento/framework/Image/Adapter/Gd2.php
+++ b/vendor/magento/framework/Image/Adapter/Gd2.php
@@ -538,8 +538,8 @@ class Gd2 extends AbstractAdapter
} elseif ($this->getWatermarkPosition() == self::POSITION_STRETCH) {
$watermark = $this->createWaterMark($watermark, $this->_imageSrcWidth, $this->_imageSrcHeight);
} elseif ($this->getWatermarkPosition() == self::POSITION_CENTER) {
- $positionX = $this->_imageSrcWidth / 2 - imagesx($watermark) / 2;
- $positionY = $this->_imageSrcHeight / 2 - imagesy($watermark) / 2;
+ $positionX = (int) ($this->_imageSrcWidth / 2 - imagesx($watermark) / 2);
+ $positionY = (int) ($this->_imageSrcHeight / 2 - imagesy($watermark) / 2);
$this->imagecopymergeWithAlphaFix(
$this->_imageHandler,
$watermark,
And for ImageMagick: index 5cfa7fe..099a960 100644
--- a/vendor/magento/framework/Image/Adapter/ImageMagick.php
+++ b/vendor/magento/framework/Image/Adapter/ImageMagick.php
@@ -326,8 +326,8 @@ class ImageMagick extends AbstractAdapter
$watermark->sampleImage($this->_imageSrcWidth, $this->_imageSrcHeight);
break;
case self::POSITION_CENTER:
- $positionX = ($this->_imageSrcWidth - $watermark->getImageWidth()) / 2;
- $positionY = ($this->_imageSrcHeight - $watermark->getImageHeight()) / 2;
+ $positionX = (int) (($this->_imageSrcWidth - $watermark->getImageWidth()) / 2);
+ $positionY = (int) (($this->_imageSrcHeight - $watermark->getImageHeight()) / 2);
break;
case self::POSITION_TOP_RIGHT:
$positionX = $this->_imageSrcWidth - $watermark->getImageWidth(); |
I've had this same issue with more or less the exact experience as @craig-bartlett . This is a bug in the code and the ticket needs reopening. One thing I would add, you can generate the error by running bin/magento catalog:image:resize (I saved time by hardcoding the particular image I was having trouble with) |
@sdzhepa, @engcom-Dash: can we reopen this ticket and redo the testing based on the last 2 comments? Thanks! 🙂 |
- Cast resized image dimensions from floats to integers for GD and ImageMagick as imagecopy expects ints
…ints magento#35535: Magento 2.4.4 Mini cart item images not showing
@hostep Sorry I've not had much free time lately - the PR attached is how I fixed the issue on our instances. Hopefully I created the PR correctly, please advise if not! |
Awesome, thanks! |
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://bbe1a762f962e3fafff870ef0572ba49.instances.magento-community.engineering |
Hello @khoimm92 , Please refer the below screenshot for the reference; We have followed the below steps in order to reproduce the issue: |
Hi, for reference the following steps are required to trigger the bug:
As @benyatesvortex said above - you can trigger the error after by running bin/magento catalog:image:resize |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-6939 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Lima. Thank you for verifying the issue. |
Its not only cart and checkout, its on every page where an image from a product exists. When passing the positionX and positionY to this function, its always an int. But it can become a float when caculations are made. That happens not only on line https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L541 But also on: https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L542 |
Preconditions and environment
Steps to reproduce
bin/magento catalog:image:resize
and observe the error in the terminal.Expected result
All item images in Minicart get the images
Actual result
All item images are replaced by the default Product placeholder image
Additional information
I have debugged in this file
vendor/magento/module-catalog/Helper/Image.php
then got those errors
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: