4

I met one strange issue in Magento 2 - I’m trying to change default uploading image size from 800x1200 to 934x1400.

I modified view.xml and now uploaded images going straight to folder media/catalog/product/cache/1/image/934x1400/

<image id="product_page_main_image" type="image">
                <width>934</width>
                <height>1400</height>
</image>
<image id="product_page_main_image_default" type="image">
                <width>934</width>
                <height>1400</height>
</image>
<image id="product_page_image_large" type="image">
                <width>934</width><!-- 800 -->
                <height>1400</height><!-- 1090 -->
</image>
<image id="product_page_image_medium" type="image">
                <width>934</width><!-- 800 -->
                <height>1400</height><!-- 1090 -->
</image>

But their actual size is still 800x1200

Any ideas how to solve this issue? I can’t find any settings to modify default uploading image size.

3
  • Can you show your change to view.xml?
    – Aravona
    Commented Nov 3, 2016 at 14:31
  • <image id="product_page_main_image" type="image"> <width>934</width> <height>1400</height> </image> <image id="product_page_main_image_default" type="image"> <width>934</width> <height>1400</height> </image> <image id="product_page_image_large" type="image"> <width>934</width><!-- 800 --> <height>1400</height><!-- 1090 --> </image> <image id="product_page_image_medium" type="image"> <width>934</width><!-- 800 --> <height>1400</height><!-- 1090 --> </image> Commented Nov 3, 2016 at 14:38
  • github.com/magento/magento2/issues/13747
    – Detzler
    Commented Feb 20, 2018 at 13:52

2 Answers 2

8

There are two ways to change max resizing width & height of the image after uploading:

1) Magento\Framework\File\Uploader.php contain constants MAX_IMAGE_HEIGHT & MAX_IMAGE_WIDTH which is set to 1200 by default

2) magento/module-backend/view/adminhtml/templates/media/uploader.phtml contains PHP code for echo same constants MAX_IMAGE_HEIGHT and MAX_IMAGE_WIDTH. You can just hardcode your value instead these values.

5
  • Did you succeed overwide the Magento\Framework\File\Uploader.php class ? Commented Nov 21, 2016 at 10:52
  • 1
    I made module for this: bitbucket.org/fred_imgmedia/imageproccess Commented Nov 22, 2016 at 13:59
  • For information your module do not manage all cases. Check my answer magento.stackexchange.com/questions/126420/… . Why do you not use your constant of your Uploader class inside template ? Commented Nov 24, 2016 at 10:17
  • Can you update your answer with these locations : vendor/magento/module-cms/view/adminhtml/templates/browser/content/uploader.phtml:103 vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml:17 vendor/magento/module-configurable-product/view/adminhtml/web/js/variations/steps/bulk.js:317 Commented Nov 24, 2016 at 10:18
  • In the newest versions of Magento, you can navigate to Stores -> Configuration -> Advanced -> System -> Images Upload Configuration in admin panel. There you will see the settings and you don't need a module anymore to override this Commented Mar 2, 2020 at 15:45
3

Some clarification:

The upload image size limitation is done in multiple area :

Upload images on configurable product creation steps:

vendor/magento/module-configurable-product/view/adminhtml/web/js/variations/steps/bulk.js:317

Upload image for a product

vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml:17

Upload image for CMS

vendor/magento/module-cms/view/adminhtml/templates/browser/content/uploader.phtml:103

Abstract class with the constant value

vendor/magento/framework/File/Uploader.php:138

To my mind Magento has not finished to implement correctly this feature because the value is harcoded for the configurable creation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.