WordPress 5.8 added native support to allow uploading WebP images just like PNG, JPEG. WebP images are supposed to be smaller in size and make the web faster.
WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.
The WebP image format is developed by Google and you can read more details on the new image format.
WebP In WordPress Multisite
WebP images are not automatically supported on WordPress multi-sites. WordPress multi-site users are still not allowed to upload WebP images. It’s sad but true.
While this is in the roadmap for the future, in the meantime, you can add WebP image support on WordPress multi-sites with a little custom code:
// Ensure all network sites include WebP support.
add_filter(
'site_option_upload_filetypes',
function ( $filetypes ) {
$filetypes = explode( ' ', $filetypes );
if ( ! in_array( 'webp', $filetypes, true ) ) {
$filetypes[] = 'webp';
$filetypes = implode( ' ', $filetypes );
}
return $filetypes;
}
);
If you’re not familiar with custom code snippets, you can read the article on how to easily add custom code in WordPress.
WebP in WordPress 5.7 or lower
For the users using WordPress 5.7 or lower, we’ll just need a little code snippet to allow uploading WebP images.
add_filter( 'upload_mimes', function( $mimes ) {
$mimes['webp'] = 'image/webp';
return $mimes;
} );
Did you know? You can see who is currently online in your WordPress site!
I hope you found this helpful!