Make WordPress Core


Ignore:
Timestamp:
02/02/2024 05:46:50 PM (2 years ago)
Author:
adamsilverstein
Message:

Media: enable AVIF support.

Add support for uploading, editing and saving AVIF images when supported by the server.

Add 'image/avif' to supported mime types. Correctly identify AVIF images and sizes even when PHP doesn't support AVIF. Resize uploaded AVIF files (when supported) and use for front end markup.

Props adamsilverstein, lukefiretoss, ayeshrajans, navjotjsingh, Tyrannous, jb510, gregbenz, nickpagz, JavierCasares, mukesh27, yguyon, swissspidy.
Fixes #51228.

File:
1 edited

Legend:

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

    r56547 r57524  
    220220                    }
    221221                    break;
     222                case 'image/avif':
    222223                default:
    223224                    $this->image->setImageCompressionQuality( $quality );
     
    255256        if ( ! $height ) {
    256257            $height = $size['height'];
     258        }
     259
     260        /*
     261         * If we still don't have the image size, fall back to `wp_getimagesize`. This ensures AVIF images
     262         * are properly sized without affecting previous `getImageGeometry` behavior.
     263         */
     264        if ( ( ! $width || ! $height ) && 'image/avif' === $this->mime_type ) {
     265            $size   = wp_getimagesize( $this->file );
     266            $width  = $size[0];
     267            $height = $size[1];
    257268        }
    258269
Note: See TracChangeset for help on using the changeset viewer.