Opened 5 years ago
Closed 2 months ago
#50866 closed defect (bug) (worksforme)
Media Uploader Blows Up File Sizes
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 5.4.2 |
Component: | Media | Keywords: | has-patch has-unit-tests dev-feedback needs-testing has-testing-info |
Focuses: | administration, performance | Cc: |
Description
Dear Developers,
this is a flaw in the media uploader that is very simple to reproduce:
create a 512x512 PNG image with best compression,
make sure that your wordpress is set to create small, medium, and large versions of that image,
set one of those versions to be also 512x512px, so when you upload a 512x512px image the media manager will create a copy of that image with the same size.
upload the image.
wordpress's uploader will not use the original 512x512px PNG image when this size is requested by a page, but instead it will use its own 512x512px image that it has created, and
compare sizes - the media uploader's PNG image file is at least 3x-4x times bigger, and wordpress will use that bigger image file instead of the smaller original of the same dimensions, and better compression.
Please, could you fix that?
Thank you
Attachments (4)
Change History (26)
#2
@
5 years ago
- Keywords has-patch has-unit-tests dev-feedback needs-testing added; needs-patch removed
Hi there, I have uploaded a patch. It changes the behaviour of image_get_intermediate_size
function to return the originale file info instead of the sub size if they share the exact same width and height.
I am not sure this need changes in other image functions. Please run some tests.
This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.
5 years ago
This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.
4 years ago
#5
@
4 years ago
- Milestone changed from Awaiting Review to 5.8
Mentioned in the recent Media Component meeting, this looks like a good ticket for 5.8. Adding to the milestone for visibility.
This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.
4 years ago
This ticket was mentioned in Slack in #core-test by boniu91. View the logs.
4 years ago
#10
@
4 years ago
I wasn't able to reproduce it. When adding media to the Gutenberg page, it's using the compressed version, not the generated one:
While on the server there was a specific copy available:
-rw-rw-r-- 1 ubuntu ubuntu 8.9K May 7 13:52 Webp.net-compress-image-2.jpg -rw-rw-r-- 1 ubuntu ubuntu 4.3K May 7 13:52 Webp.net-compress-image-2-300x122.jpg -rw-rw-r-- 1 ubuntu ubuntu 23K May 7 13:52 Webp.net-compress-image-2-1024x416.jpg -rw-rw-r-- 1 ubuntu ubuntu 3.1K May 7 13:52 Webp.net-compress-image-2-150x150.jpg -rw-rw-r-- 1 ubuntu ubuntu 14K May 7 13:52 Webp.net-compress-image-2-768x312.jpg **-rw-rw-r-- 1 ubuntu ubuntu 13K May 7 13:52 Webp.net-compress-image-2-1536x624.jpg**
#11
@
4 years ago
- Milestone changed from 5.8 to 5.9
Today is 5.8 Beta 1. As @Boniu91 was unable to reproduce, it needs more time. Punting to 5.9 to continue progress towards resolution.
#12
@
4 years ago
Running WP 5.9-alpha-51272-src
, I took a 512x512 png image and ran through optimization to reduce its size to 1.5K and when I uploaded this image 512x512-2.png
directly to the media library, an additional 512x512 image was indeed created even though I had set the medium size as 512x512. And we can see the size of that copy is bigger than the original size (3.2K).
-rw-r--r-- 1 ashfame staff 902B Aug 5 18:45 512x512-2-150x150.png -rw-r--r-- 1 ashfame staff 3.2K Aug 5 18:45 512x512-2-512x512.png -rw-r--r-- 1 ashfame staff 1.5K Aug 5 18:45 512x512-2.png
Exactly the same thing happened when I uploaded it directly from WordPress block editor (without Gutenberg plugin) while creating a post. But the image that was actually added in the post was the original image. So, this issue couldn't be reproduced.
I took a quick look at the patch but chose not to test it at all as its about changing the logic of choosing which image to select for a particular size (which doesn't seem to be an issue anymore) and nothing about preventing the additional image size from being generated (which is still an issue, though a trivial one).
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
4 years ago
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 years ago
#15
@
3 years ago
- Milestone changed from 5.9 to 6.0
This may need more discussion before the release candidate cutoff for WordPress 5.9. I am going to move this to future release but if anyone wants to champion this issue and help find any unintended consequences please feel free to test and provide your findings here in this ticket. thanks!
#16
@
3 years ago
- Patch has been refreshed against
trunk
. - Added
$message
parameter to the unit test's assertions. - The unit tests appear to be failing on my end.
This ticket was mentioned in Slack in #core by costdev. View the logs.
3 years ago
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
3 years ago
#21
@
3 years ago
- Milestone changed from 6.0 to Future Release
As there hasn't been any movement since @costdev reported apparent unit test failures, I'll move this to a future release as RC1 is next week.
#22
@
2 months ago
- Milestone Future Release deleted
- Resolution set to worksforme
- Status changed from assigned to closed
This should be fixed by https://core.trac.wordpress.org/changeset/59589 - closing as such.
I tested with the image attached to the ticket, using Imagick to process the image (where the bug was causing 8 bit images to blow up to 24 bit images). All generated images were smaller than the upload.
If you can still reproduce this issue, please re-open the issue.
Thanks for the report!
Just linking to a ticket that might be related: #47713.