Make WordPress Core

Opened 5 years ago

Last modified 5 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 Owned by:
Priority: normal Milestone: Future Release
Component: Media Version: 5.8
Severity: normal Keywords: needs-patch has-screenshots
Cc: Focuses:

Description

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 5 years ago.
Screenshot of Media Library displaying incorrect mime type.

Download all attachments as: .zip

Change History (8)

@ianmjones
5 years ago

Screenshot of Media Library displaying incorrect mime type.

#1 @desrosj
5 years ago

  • Milestone Awaiting Review5.8.1

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


5 years ago

#3 @desrosj
5 years ago

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

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

#4 @azaozz
5 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
5 years ago

  • Keywords needs-patch has-screenshots added
  • Milestone 5.8.15.8.2

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

#6 @desrosj
5 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
5 years ago

  • Milestone 5.8.2Future 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.