[wp-trac] [WordPress Trac] #55443: Create WebP sub-sizes and use for output

WordPress Trac noreply at wordpress.org
Thu Jul 21 18:01:16 UTC 2022


#55443: Create WebP sub-sizes and use for output
-------------------------------------------------+-------------------------
 Reporter:  adamsilverstein                      |       Owner:
                                                 |  adamsilverstein
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Media                                |     Version:  6.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:
  note needs-docs needs-user-docs commit         |  performance
-------------------------------------------------+-------------------------

Comment (by adamsilverstein):

 In [changeset:"53751" 53751]:
 {{{
 #!CommitTicketReference repository="" revision="53751"
 Media: enable generating multiple mime types for image uploads;
 specifically WebP versions for JPEG images by default.

 This changeset adds the capability for core media uploads to generate sub
 sized images in more than a single mime type. The output formats for each
 mime type can be controlled through a filter. WebP is used as an
 additional output format for JPEG images by default to improve front end
 performance.

 When generating additional mime types, only images which are smaller than
 the respective original are retained. By default, additional mime type
 images are only generated for the built-in core image sizes and any custom
 sizes that have opted in.

 Image meta is updated with a new 'sources' array containing file details
 for each mime type. Each image size in the 'sizes' array also gets a new
 'sources' array that contains the image file details for each mime type.

 This change also increases image upload retries to accommodate additional
 image sizes. It also adds a `$mime_type` parameter to the
 `wp_get_missing_image_subsizes` function and filter.

 This change adds three new filters to enable full control of secondary
 mime image generation and output:

 * A new filter `wp_image_sizes_with_additional_mime_type_support` that
 filters the sizes that support secondary mime type output. Developers can
 use this to control the output of additional mime type sub-sized images on
 a per size basis.
 * A new filter `wp_upload_image_mime_transforms` that filters the output
 mime types for a given input mime type. Developers can use this to control
 generation of additional mime types for a given input mime type or even
 override the original mime type.
 * A new filter `wp_content_image_mimes` which controls image mime type
 output selection and order for frontend content. Developers can use this
 to control the mime type output preference order for content images.
 Content images inserted from the media library will use the available
 image versions based on the order from this filter.

 Thanks to the many contributors who helped develop, test and give feedback
 on this feature.

 A haiku to summarize:

 Upload a JPEG
 Images of all sizes
 Output as WebPs

 Props flixos90, MatthiasReinholz, studiolxv, markhowellsmead, eatingrules,
 pbiron, mukesh27, joegrainger, mehulkaklotar, tweetythierry, akshitsethi,
 peterwilsoncc, eugenemanuilov, mitogh, shetheliving, clarkeemily,
 codekraft, mikeschroder, clorith, kasparsd, spacedmonkey,
 trevorpfromsandee, jb510, scofennellgmailcom, seedsca, cagsmith,
 karinclimber, dainemawer, baxbridge, grapplerulrich, sobatkras,
 chynnabenton, tonylocalword, barneydavey, kwillmorth, garymatthews919,
 olliejones, imarkinteractive, jeffpaul, feastdesignco, webbeetle,
 masteradhoc.

 See #55443.
 }}}

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


More information about the wp-trac mailing list