An Easy Way to Allow WordPress to Upload WebP Images – WordPress Tutorial

By | December 22, 2020

WordPress does not allows us to upload webp images. In this tutorial, we will introduce you how to make wordpress can upload webp images.

For example, if you upload a webp image in wordpress, you will find this error:

wordpress not allow to upload webp images

How to upload webp images in wordpress?

We will tell you how to do.


You should make your wordpress version 5.2+

Open your theme function.php file

Copy and paste code below in your function.php file.

//** *Enable upload for webp image files.*/
function webp_upload_mimes($existing_mimes) {
    $existing_mimes['webp'] = 'image/webp';
    return $existing_mimes;
add_filter('mime_types', 'webp_upload_mimes');
//** * Enable preview / thumbnail for webp image files.*/
function webp_file_is_displayable_image($result, $path) {
    $info = @getimagesize( $path );
    if($info['mime'] == 'image/webp') {
        $result = true;
    return $result;
add_filter( 'file_is_displayable_image', 'webp_file_is_displayable_image', 10, 2 );

Then you will find you can upload webp images in wordpress.

wordpress allows to upload webp images