[wp-trac] [WordPress Trac] #56349: Update WordPress core functions to support multiple MIME types

WordPress Trac noreply at wordpress.org
Mon Aug 8 14:06:16 UTC 2022


#56349: Update WordPress core functions to support multiple MIME types
-------------------------+-----------------------------
 Reporter:  joegrainger  |      Owner:  joegrainger
     Type:  enhancement  |     Status:  assigned
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Media        |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  performance  |
-------------------------+-----------------------------
 As part of an effort to improve performance within WordPress, WebP image
 generation has been introduced into core for new uploads. In order for
 WebP images to be used outside of user-editable content, WordPress core
 image functions will be updated to allow developers to specify what MIME
 type to return for an attachment.

 The proposal is to update the `wp_get_attachment_image_src` function by
 replacing the `$icon` parameter with a `$args` parameter. This new
 parameter will allow developers to requests a specific attachment mime
 type source.

 To accommodate this change a new `wp_get_attachment_preview_src` function
 will be created. This function is intended to replace all instances in
 WordPress core where `wp_get_attachment_image_src` is called and the
 `$icon` parameter is set to true.

 Additionally, all core functions that have an `$icon` parameter will be
 updated to accept the new `$args` parameter and pass this to the
 `wp_get_attachment_image_src` function.

 For backward compatibility the `$args` parameter can be passed as a
 boolean and work the same as the original `$icon` parameter.

 The `$args` parameter will accept 2 keys, `icon` and `mime_type`. The
 `icon` argument will work the same as the original `$icon` parameter and
 will return the files MIME type icon when set to `true`. The `mime_type`
 argument is used to define the preferred image MIME to return. If the MIME
 type requested is not available, the original image MIME type is returned.

 Lastly, the `image_downsize` and `image_get_intermediate_size` functions
 will be updated with a new `$mime_type` parameter. This will be used to
 return the correct file for the specified MIME type.

 Patch incoming.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56349>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list