Make WordPress Core


Ignore:
Timestamp:
02/02/2024 05:46:50 PM (3 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-admin/includes/image-edit.php

    r56653 r57524  
    391391                                }
    392392                                return false;
     393                        case 'image/avif':
     394                                if ( function_exists( 'imageavif' ) ) {
     395                                        header( 'Content-Type: image/avif' );
     396                                        return imageavif( $image, null, 90 );
     397                                }
     398                                return false;
    393399                        default:
    394400                                return false;
    … …  
    493499                                if ( function_exists( 'imagewebp' ) ) {
    494500                                        return imagewebp( $image, $filename );
     501                                }
     502                                return false;
     503                        case 'image/avif':
     504                                if ( function_exists( 'imageavif' ) ) {
     505                                        return imageavif( $image, $filename );
    495506                                }
    496507                                return false;
Note: See TracChangeset for help on using the changeset viewer.