Make WordPress Core


Ignore:
Timestamp:
10/29/2024 01:11:00 AM (4 months ago)
Author:
azaozz
Message:

Media: Fix uploading of .heic images.

  • Adds support for all HEIC/HEIF mime types: image/heic, image/heif, image/heic-sequence, and image/heif-sequence.
  • Introduces wp_is_heic_image_mime_type().

Props swissspidy, adamsilverstein, debarghyabanerjee, ironprogrammer, peterwilsoncc, apermo, azaozz.
Fixes #62272.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r59189 r59315  
    56285628function wp_getimagesize( $filename, ?array &$image_info = null ) {
    56295629    // Don't silence errors when in debug mode, unless running unit tests.
    5630     if ( defined( 'WP_DEBUG' ) && WP_DEBUG
    5631         && ! defined( 'WP_RUN_CORE_TESTS' )
    5632     ) {
     5630    if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! defined( 'WP_RUN_CORE_TESTS' ) ) {
    56335631        if ( 2 === func_num_args() ) {
    56345632            $info = getimagesize( $filename, $image_info );
     
    56615659    }
    56625660
     5661    $image_mime_type = wp_get_image_mime( $filename );
     5662
     5663    // Not an image?
     5664    if ( false === $image_mime_type ) {
     5665        return false;
     5666    }
     5667
    56635668    /*
    56645669     * For PHP versions that don't support WebP images,
    56655670     * extract the image size info from the file headers.
    56665671     */
    5667     if ( 'image/webp' === wp_get_image_mime( $filename ) ) {
     5672    if ( 'image/webp' === $image_mime_type ) {
    56685673        $webp_info = wp_get_webp_info( $filename );
    56695674        $width     = $webp_info['width'];
     
    56875692
    56885693    // For PHP versions that don't support AVIF images, extract the image size info from the file headers.
    5689     if ( 'image/avif' === wp_get_image_mime( $filename ) ) {
     5694    if ( 'image/avif' === $image_mime_type ) {
    56905695        $avif_info = wp_get_avif_info( $filename );
    56915696
     
    57105715
    57115716    // For PHP versions that don't support HEIC images, extract the size info using Imagick when available.
    5712     if ( 'image/heic' === wp_get_image_mime( $filename ) ) {
     5717    if ( wp_is_heic_image_mime_type( $image_mime_type ) ) {
    57135718        $editor = wp_get_image_editor( $filename );
     5719
    57145720        if ( is_wp_error( $editor ) ) {
    57155721            return false;
    57165722        }
     5723
    57175724        // If the editor for HEICs is Imagick, use it to get the image size.
    57185725        if ( $editor instanceof WP_Image_Editor_Imagick ) {
Note: See TracChangeset for help on using the changeset viewer.