WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/04/2021 02:43:36 PM (7 months ago)
Author:
adamsilverstein
Message:

Images: enable WebP support.

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

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

Props markoheijne, blobfolio, Clorith, joemcgill, atjn, desrosj, spacedmonkey, marylauc, mikeschroder, hellofromtonya, flixos90.
Fixes #35725.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r50560 r50810  
    307307                header( 'Content-Type: image/gif' );
    308308                return imagegif( $image );
     309            case 'image/webp':
     310                if ( function_exists( 'imagewebp' ) ) {
     311                    header( 'Content-Type: image/webp' );
     312                    return imagewebp( $image, null, 90 );
     313                }
     314                return false;
    309315            default:
    310316                return false;
     
    392398            case 'image/gif':
    393399                return imagegif( $image, $filename );
     400            case 'image/webp':
     401                if ( function_exists( 'imagewebp' ) ) {
     402                    return imagewebp( $image, $filename );
     403                }
     404                return false;
    394405            default:
    395406                return false;
Note: See TracChangeset for help on using the changeset viewer.