Make WordPress Core


Ignore:
Timestamp:
02/02/2024 05:46:50 PM (12 months 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/tests/phpunit/tests/image/functions.php

    r56559 r57524  
    112112            'webp-lossy.webp',
    113113            'webp-transparent.webp',
     114            'avif-animated.avif',
     115            'avif-lossless.avif',
     116            'avif-lossy.avif',
     117            'avif-transparent.avif',
    114118        );
    115119
     
    185189            $files[] = 'webp-lossy.webp';
    186190            $files[] = 'webp-transparent.webp';
     191        }
     192
     193        // Add AVIF images if the image editor supports them.
     194        $file   = DIR_TESTDATA . '/images/avif-lossless.avif';
     195        $editor = wp_get_image_editor( $file );
     196
     197        if ( ! is_wp_error( $editor ) && $editor->supports_mime_type( 'image/avif' ) ) {
     198            $files[] = 'avif-animated.avif';
     199            $files[] = 'avif-lossless.avif';
     200            $files[] = 'avif-lossy.avif';
     201            $files[] = 'avif-transparent.avif';
    187202        }
    188203
Note: See TracChangeset for help on using the changeset viewer.