Save resized images as WebP
The smaller copies WordPress makes of your JPEG and PNG uploads are saved as WebP, which is usually 25–35% smaller. The original upload stays as it is.
<?php
add_filter(
'image_editor_output_format',
static function ( $formats ) {
// Only when the server can actually write WebP.
if ( wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
$formats['image/jpeg'] = 'image/webp';
$formats['image/png'] = 'image/webp';
}
return $formats;
}
);
Good to know
Every current browser shows WebP. Only new uploads are affected.
In these packs
- Images and media: Sharper, lighter images, tidier uploads and a more useful media library.
- More speed: More ways to load less: block styles, speculative loading, fewer scripts.