Make WordPress Core


Ignore:
Timestamp:
08/05/2024 04:11:40 AM (21 months ago)
Author:
noisysocks
Message:

Media: Automatically convert HEIC images to JPEG

Automatically create a JPEG version of uploaded HEIC images if the server has
a version of Imagick that supports HEIC. Conversion is done silently through
the existing WP_Image_Editor infrastructure that creates multiple sizes of
uploaded images.

This allows users to view HEIC images in WP Admin and use them in their posts
and pages regardless of whether their browser supports HEIC. Browser support
for HEIC is relatively low (only Safari) while the occurrence of HEIC images is
relatively common. The original HEIC image can be downloaded via a link on
the attachment page.

Props adamsilverstein, noisysocks, swissspidy, spacedmonkey, peterwilsoncc.
Fixes #53645.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r58417 r58849  
    220220                    }
    221221                    break;
    222                 case 'image/avif':
    223222                default:
    224223                    $this->image->setImageCompressionQuality( $quality );
     
    259258
    260259        /*
    261          * If we still don't have the image size, fall back to `wp_getimagesize`. This ensures AVIF images
     260         * If we still don't have the image size, fall back to `wp_getimagesize`. This ensures AVIF and HEIC images
    262261         * are properly sized without affecting previous `getImageGeometry` behavior.
    263262         */
    264         if ( ( ! $width || ! $height ) && 'image/avif' === $this->mime_type ) {
     263        if ( ( ! $width || ! $height ) && ( 'image/avif' === $this->mime_type || 'image/heic' === $this->mime_type ) ) {
    265264            $size   = wp_getimagesize( $this->file );
    266265            $width  = $size[0];
Note: See TracChangeset for help on using the changeset viewer.