WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 4 weeks 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:
Milestone: 5.8.2 Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: needs-patch has-screenshots
Focuses: Cc:

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

Download all attachments as: .zip

Change History (7)

@ianmjones
3 months ago

Screenshot of Media Library displaying incorrect mime type.

#1 @desrosj
3 months 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 months ago

#3 @desrosj
2 months ago

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

Last edited 2 months ago by desrosj (previous) (diff)

#4 @azaozz
6 weeks 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
4 weeks 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
4 weeks ago

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

Note: See TracTickets for help on using tickets.