[wp-trac] [WordPress Trac] #53665: Incorrect mime type saved on attachment for scaled/rotated images processed with image_editor_output_format filter

WordPress Trac noreply at wordpress.org
Thu Jul 15 11:30:14 UTC 2021


#53665: Incorrect mime type saved on attachment for scaled/rotated images processed
with image_editor_output_format filter
--------------------------+-----------------------------
 Reporter:  ianmjones     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When the `image_editor_output_format` filter is used to change the format
 of jpeg images during the upload of a new large or rotated image, the mime
 type saved to the `posts` table record is for the `original_image` and not
 the `-scaled` or `-rotated` "full" size image that is used throughout the
 admin area.

 Example filter:

 {{{
 add_filter( 'image_editor_output_format', function( $formats ) {
         $formats['image/jpeg'] = 'image/webp';

         return $formats;
 } );

 }}}


 From an original file called "picture.jpg" this will produce a file called
 "picture-scaled.webp" that is used in the Media Library.

 When viewing the details of the image from the Media Library's grid view,
 the overlay panel shows the mime type of the webp file as "image/jpeg".
 See attached screenshot for an example.

 This may confuse some users.

 It may also have a knock-on effect for themes or plugins that use the
 stored mime type rather than deduce it from a file's extension.

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


More information about the wp-trac mailing list