Make WordPress Core


Ignore:
Timestamp:
11/07/2024 01:25:10 AM (15 months ago)
Author:
peterwilsoncc
Message:

Media: Fix converting of all HEIC/HEIF images to JPEGs after uploading regardless of dimensions.

This backport includes follow up commits to improve a variable name and improve accuracy of when an image needs to be converted.

Reviewed by peterwilsoncc.
Merges [59317], [59346], [59366] to the 6.7 branch.

Props ironprogrammer, adamsilverstein, azaozz, peterwilsoncc, apermo, flixos90.
Fixes #62305.

Location:
branches/6.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-includes/media.php

    r59360 r59367  
    62346234 */
    62356235function wp_get_image_editor_output_format( $filename, $mime_type ) {
     6236    $output_format = array(
     6237        'image/heic'          => 'image/jpeg',
     6238        'image/heif'          => 'image/jpeg',
     6239        'image/heic-sequence' => 'image/jpeg',
     6240        'image/heif-sequence' => 'image/jpeg',
     6241    );
     6242
    62366243    /**
    62376244     * Filters the image editor output format mapping.
    62386245     *
    6239      * Enables filtering the mime type used to save images. By default,
    6240      * the mapping array is empty, so the mime type matches the source image.
     6246     * Enables filtering the mime type used to save images. By default HEIC/HEIF images
     6247     * are converted to JPEGs.
    62416248     *
    62426249     * @see WP_Image_Editor::get_output_format()
    62436250     *
    62446251     * @since 5.8.0
    6245      * @since 6.7.0 The default was changed from array() to array( 'image/heic' => 'image/jpeg' ).
     6252     * @since 6.7.0 The default was changed from an empty array to an array
     6253     *              containing the HEIC/HEIF images mime types.
    62466254     *
    62476255     * @param string[] $output_format {
    62486256     *     An array of mime type mappings. Maps a source mime type to a new
    6249      *     destination mime type. Default maps uploaded HEIC images to JPEG output.
     6257     *     destination mime type. By default maps HEIC/HEIF input to JPEG output.
    62506258     *
    62516259     *     @type string ...$0 The new mime type.
     
    62546262     * @param string $mime_type The source image mime type.
    62556263     */
    6256     return apply_filters( 'image_editor_output_format', array( 'image/heic' => 'image/jpeg' ), $filename, $mime_type );
    6257 }
     6264    return apply_filters( 'image_editor_output_format', $output_format, $filename, $mime_type );
     6265}
Note: See TracChangeset for help on using the changeset viewer.