4

Is anyone else seeing issues with uploading images through the WYSIWYG editor in the admin as far as images becoming larger? For example, I uploaded a JPG image optimized in Photoshop that's 168KB but after uploading it's over 460KB.

I looked into the patch code and it looks like they're resampling images and saving them at 100% quality in the validate method (core/Mage/Core/Model/File/Validator/Image.php) instead of just passing the image as uploaded into the wysiwyg media directory.

I've applied V2 of the patch as well as trying to update the code myself from the many other posts here that were dealing with the PNG background issue but the issue is always going to be that they're doing imagejpeg($img, $filePath, 100);. This is recreating the image at 100% quality and that's a big problem.

Am I crazy or are other people able to duplicate this? If so, this is a huge problem for store owners as they'll start seeing their Google Page Speed score go down because images are now so large.

3 Answers 3

4

Turn off the image reprocessing.

insert into vbstag_mag.core_config_data (scope, scope_id, path, value) values('default','0','general/reprocess_images/active','0')

I'm unable to find a front end configuration for this.

7
  • Works as intended. Any drawbacks? Commented Dec 20, 2017 at 13:28
  • 1
    @HåvardGeithus I haven't released to production yet, but from what I understand it opens you up to possible attacks from uploads. I'll add more once I have a chance to do a bit more research. Right now it's sitting in my queue. Since all my uploads happen on the backend I'm feeling confident.
    – TheRealJAG
    Commented Dec 29, 2017 at 17:11
  • That's what I figured as well. All our uploads are done by trusted admins. Commented Jan 1, 2018 at 22:55
  • 1
    @HåvardGeithus "trusted admins"... You never know who gets access to your admin area because of another exploit...
    – Simon
    Commented Jul 3, 2018 at 14:02
  • That's a fair point. Commented Jul 3, 2018 at 16:01
2

I have made this change in: core/Mage/Core/Model/File/Validator/Image.php

from:

case IMAGETYPE_JPEG:
  imagejpeg($img, $filePath, 100);

to

case IMAGETYPE_JPEG:
  imagejpeg($img, $filePath);

and jpg loaded via wysiwyg editor retain their initial file size.

0

I have tested image upload with 1.7 and 1.9 Magento with SUPEE 9767 (V2) patch installed. Images DO NOT become larger on my end. In fact they decrease in size upon upload. .jpg image of 500kb, after upload it is uploaded and stored on server as 150kb

Please check this topic, it might have an answer. https://stackoverflow.com/questions/16657540/magento-increases-image-sizes-on-the-front-end

10
  • I'm not at all able to replicate this. One of my clients is on magento 1.8 with all patches installed and with the image below, it gets bigger whether I optimize it photoshop or not. image here, (1.5MB) and this is what it was upscaled too after I uploaded it 2MB. uploaded image Commented Jul 25, 2017 at 17:50
  • The same issue happened when I did this on another client with 1.9.1 installed. I'm doing all this through the WYSIWYG Image Upload functionality. Commented Jul 25, 2017 at 18:18
  • 1
    I think it's the validate method in core/Mage/Core/Model/File/Validator/Image.php which also updated by the patch and v2 of the patch but the jpg section stayed the same. All it is is imagejpeg($img, $filePath, 100); which is the line responsible for recreating the image. Before the path, this method simply moved the uploaded file to media/wysiwyg directory. Commented Jul 25, 2017 at 19:03
  • 2
    I can confirm @where_is_bills assumption. I did some testing here and the problem is definitely the JPG re-conversion. In my tests I saw 90kB JPEGs blow up to 600kB. Commented Aug 31, 2017 at 18:47
  • 1
    where exactly in admin pane l can we turn on or off image reprocessing ?
    – Icon
    Commented Sep 18, 2017 at 19:37

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.