Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#52752 closed feature request (duplicate)

Add basic image compression to WordPress core

Reported by: nem0's profile nem0 Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.7
Component: Media Keywords:
Focuses: performance Cc:

Description (last modified by SergeyBiryukov)

Dear developers,

I noticed that WordPress does no basic image compression when you upload a file resulting in images with huge and unecessary file size on many websites.
Here is an example:
It's a tiny JPG I found on a wordpress website with a resolution of 100x50 pixel. The filesize for some reason is 8.7 megabyte. If I upload this image wordpress just takes it and it remains at the bloated filesize of 8.7 megabyte.

Why is this a problem?
I know that there are many plugins which take care of image compression in WordPress (Imagify, TinyJPG, Smush, ...). But I would suggest there needs to be some basic (lossless) image compression in Wordpress out of the box because many people don't install such plugins.

I recently ran a study in Germany, analyzing the filesize of thousands random Germany websites. Some websites had a file size of 10, 20 or 50 megabytes. When I took a closer look at them I found that most of them were Wordpress websites with huge images (3 megabyte or more each) that were just uploaded and not compressed by any plugin.

Google has also announced that the speed (and therefore size) of a website will have a bigger impact on the ranking through its Web Vitals (see Obviously this is an even bigger issue on mobile devices.

Hope I made my argument clear and have not missed any feature that is already there ;)


Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Description modified (diff)
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the ticket.

Just noting that WordPress does in fact have built-in image compression for intermediate image sizes, see the WP_Image_Editor::set_quality() method and these posts for more details:

Increased image compression for custom sizes
WordPress 4.5 increases the amount of compression applied to intermediate sizes by changing the default quality in WP_Image_Editor from 90 to 82. As noted in the proposal for this change, this results in a noticeable reduction in file sizes with little change in visual quality. Developers can override the default image quality value using the wp_editor_set_quality filter.

That said, WordPress always stores the original uploaded image without any modifications so it could be reused in the future to create new intermediate copies if there are any changes to custom image sizes. Since I don't think we want to change that at this time (creating resized copies from other copies would result in quality loss, as noted in #19679), I'm not sure how actionable this ticket would be.

Ticket #37840 suggests adding a new image size to WordPress that is an optimized version of the original image, and using that on the front end instead of the original uploaded image. This appears to be similar to what is being proposed here, so I think the discussion can continue there.

In the future, this could be improved further with dynamic image resizing, see tickets #15311 and #21810.

Note: See TracTickets for help on using tickets.