[wp-trac] [WordPress Trac] #37840: Optimize full size images

WordPress Trac noreply at wordpress.org
Thu Mar 30 22:33:38 UTC 2017


#37840: Optimize full size images
-------------------------+------------------------
 Reporter:  joemcgill    |       Owner:  enshrined
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  4.8
Component:  Media        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+------------------------

Comment (by enshrined):

 Ok, so hopefully this is a good start.


 == '''Changes:''' ==


 Added ‘full’ to the list of default sizes in
 `get_intermediate_image_sizes()` this allows us to use it as an actual
 image size later on.

 In `wp_generate_attachment_metadata()` I’ve updated the default for the
 `get_option()` calls to get the default image sizes from the DB. Instead
 of `false`, these will now return the original height and width of the
 image as determined earlier in the function.

 Three new methods have been added into `class-wp-image-editor.php`.
 There’s a getter and setter for the minimum file size change as a
 percentage (default is 15%) as well as a main
 `can_save_optimised_full_size()` method that does the checking for whether
 we have compressed over the minimum file size change or not.

 There’s also a new `wp_image_set_minimum_filesize_difference` filter that
 allows filtering of the difference as a percentage.

 Other than that, the checks have been added to the ImageMagick and GD
 editor classes to skip the duplicate check if we’re on the `full` size and
 the `can_save_optimised_full_size()` method returns `true`.

 From what I’ve seen so far with basic uploading and outputting on
 pages/posts this seems to work seamlessly and just replace the original
 image with the optimised version.

 It was mentioned on Slack that re-using `full` may lead to issues with
 themes/plugins using this size and expecting to get the original image so
 that’s open to discussion.

 I’ve seen full size images drop from 22.3MB to 3.6MB and 17.5MB to 2.8MB
 respectively so this is definitely a good thing if using `full` doesn’t
 break anything.

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


More information about the wp-trac mailing list