Magento Asked by Adam Moss on November 8, 2021
When uploading new images to a product in Magento 2, it is not only decreasing the dimensions of the image, but it’s increasing the image file size:
Image Details Before Upload
After Upload
Can anybody explain why this is happening? I accept that some data may be added to the image by Magento, but I don’t understand why it has been resized? Is there anywhere this can be changed?
EDIT
I’ve now discovered that the image dimensions have been set in vendor/magento/framework/File/Uploader.php
Next is to find the best way to change these values, I found this related post: Magento 2 change max image height and width of image uploader in Admin?
I still don’t know why these dimensions have been imposed on users on M2. nor why the file size more than doubles in size!
Now the max image size can be set at Stores > Settings > Configuration > Advanced > System > Images Upload Configuration
see https://docs.magento.com/user-guide/catalog/product-image-resizing.html
Answered by Victor L on November 8, 2021
In the end I created a new theme to override the following two files where the restriction was added:
vendor/magento/module-cms/view/adminhtml/templates/browser/content/uploader.phtml
vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml
Within those files I hard coded the new max image sizes:
"maxWidth":3000,
"maxHeight":3000
This is the post I followed to achieve the override: https://magento.stackexchange.com/a/153968/191
Regarding the image file size I have not found a definitive answer as to why the size has more than doubled. This post had some insight however: https://stackoverflow.com/questions/14008524/why-smaller-png-image-takes-up-more-space-than-the-original-after-getting-resize
Answered by Adam Moss on November 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP