mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-07 08:07:16 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@50810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -306,6 +306,12 @@ function wp_stream_image( $image, $mime_type, $attachment_id ) {
|
||||
case 'image/gif':
|
||||
header( 'Content-Type: image/gif' );
|
||||
return imagegif( $image );
|
||||
case 'image/webp':
|
||||
if ( function_exists( 'imagewebp' ) ) {
|
||||
header( 'Content-Type: image/webp' );
|
||||
return imagewebp( $image, null, 90 );
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -391,6 +397,11 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
|
||||
return imagepng( $image, $filename );
|
||||
case 'image/gif':
|
||||
return imagegif( $image, $filename );
|
||||
case 'image/webp':
|
||||
if ( function_exists( 'imagewebp' ) ) {
|
||||
return imagewebp( $image, $filename );
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user