Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#53665 new defect (bug)

Incorrect mime type saved on attachment for scaled/rotated images processed with image_editor_output_format filter

Reported by: ianmjones's profile ianmjones Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: needs-patch has-screenshots
Focuses: Cc:


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.

Attachments (1)

Screenshot from 2021-07-15 12-03-20@2x.png (1.7 MB) - added by ianmjones 3 years ago.
Screenshot of Media Library displaying incorrect mime type.

Download all attachments as: .zip

Change History (8)

3 years ago

Screenshot of Media Library displaying incorrect mime type.

#1 @desrosj
3 years ago

  • Milestone changed from Awaiting Review to 5.8.1

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

3 years ago

#3 @desrosj
3 years ago

Related: #53663, #53667, #53668, #53669.

Last edited 3 years ago by desrosj (previous) (diff)

#4 @azaozz
3 years ago

Seems there are two bugs here:

  • Larger images: attachment post mime type is wrong.
  • Smaller images are not converted after uploading.

Thinking that the original images smaller than the "big image threshold" should be converted. They are intended for use on the site/internet. Opened #53941 for that.

#5 @desrosj
3 years ago

  • Keywords needs-patch has-screenshots added
  • Milestone changed from 5.8.1 to 5.8.2

With less than 24 hours until 5.8.1 RC and no working patch, I'm going to punt this.

#6 @desrosj
3 years ago

I also have a strong suspicion that #53724 is a duplicate of this ticket. I asked for more testing details over there.

#7 @circlecube
3 years ago

  • Milestone changed from 5.8.2 to Future Release

There's no tested patch yet and 5.8.2 RC is due out in less than 24 hours. I'm going to punt this to a future release.

Note: See TracTickets for help on using tickets.