[wp-trac] [WordPress Trac] #52752: Add basic image compression to WordPress core

WordPress Trac noreply at wordpress.org
Wed Mar 10 09:12:53 UTC 2021


#52752: Add basic image compression to WordPress core
-----------------------------+--------------------------
 Reporter:  nem0             |       Owner:  (none)
     Type:  feature request  |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  Media            |     Version:  5.7
 Severity:  normal           |  Resolution:  duplicate
 Keywords:                   |     Focuses:  performance
-----------------------------+--------------------------
Changes (by SergeyBiryukov):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Old description:

> 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: https://bartenberger.de/wordpress-reh/wp-
> content/uploads/2021/03/60464.jpeg
> 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 https://developers.google.com/search/blog/2020/11/timing-for-page-
> experience). 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 ;)
>
> Best,
> martin

New description:

 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: https://bartenberger.de/wordpress-reh/wp-
 content/uploads/2021/03/60464.jpeg
 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
 https://developers.google.com/search/blog/2020/11/timing-for-page-
 experience). 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 ;)

 Best,
 martin

--

Comment:

 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
 [https://developer.wordpress.org/reference/classes/wp_image_editor/set_quality/
 WP_Image_Editor::set_quality()] method and these posts for more details:
 * [https://make.wordpress.org/core/2016/02/22/proposal-increase-the-
 default-image-compression-in-wordpress/ Proposal: Increase the default
 image compression in WordPress]
 * [https://make.wordpress.org/core/2016/03/12/performance-improvements-
 for-images-in-wordpress-4-5/ Performance improvements for images in
 WordPress 4.5]

 > **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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52752#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list