Make WordPress Core


Ignore:
Timestamp:
08/05/2024 04:11:40 AM (20 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-admin/includes/image.php

    r57755 r58849  
    544544 * @since 2.1.0
    545545 * @since 6.0.0 The `$filesize` value was added to the returned array.
     546 * @since 6.7.0 The 'image/heic' mime type is supported.
    546547 *
    547548 * @param int    $attachment_id Attachment ID to process.
     
    556557    $mime_type = get_post_mime_type( $attachment );
    557558
    558     if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) {
     559    if ( 'image/heic' === $mime_type || ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) ) {
    559560        // Make thumbnails and other intermediate sizes.
    560561        $metadata = wp_create_image_subsizes( $file, $attachment_id );
Note: See TracChangeset for help on using the changeset viewer.