Make WordPress Core

Opened 3 years ago

Closed 3 months ago

#56349 closed enhancement (maybelater)

Update WordPress core functions to support multiple MIME types

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

Description

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.

Change History (6)

This ticket was mentioned in PR #3074 on WordPress/wordpress-develop by jjgrainger.


3 years ago
#1

  • Keywords has-patch added

#2 @flixos90
3 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 6.1

This ticket was mentioned in Slack in #core-media by adamsilverstein. View the logs.


3 years ago

#4 @adamsilverstein
3 years ago

  • Milestone changed from 6.1 to Future Release

This is no longer needed for 6.1 because the mime output approach was changed and multi-mime was removed. This will be valuable if we re-introduce multi-mime support so marking as "Future Release"

adamsilverstein commented on PR #3074:


3 years ago
#5

@jjgrainger - Since we reverted multi-mime support this is not currently needed, though it will come in handy if we reintroduce the feature so thanks for your work here! Closing for now.

#6 @flixos90
3 months ago

  • Keywords has-patch needs-unit-tests removed
  • Milestone Future Release deleted
  • Resolution set to maybelater
  • Status changed from assigned to closed

This is still a valid effort (which FWIW I was personally involved in), but it's inactive. Particularly due to the modern image format efforts not having landed in Core, at this point it makes most sense to defer to the Modern Image Formats plugin which implements this functionality.

Given the lack of traction and years of inactivity and how complex it would be to implement this throughout all the different media areas, I think it should be closed as maybelater for now. If you see this ticket and are interested in working on it, please reopen.

Note: See TracTickets for help on using tickets.