Upload WebP Files on WordPress

WordPress gives an error when you try to upload webp files. To enable webp files uploads on wordpress copy and paste the below script in themes function.php file and save the file.

WordPress gives error message when you try to upload Webp file: Sorry, this file type is not permitted for security reasons. You may feel stumped as to how to proceed. Below I will explain how to solve the problem.

WordPress does not natively support viewing and uploading WebP files. To enable the support for WebP files just follow the steps. First login to your WordPress admin area and go to Appearance » Theme Editor and find functions.php

    //** *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');

After that copy and paste the code below at the end of the file and save it.

   //** * Enable preview / thumbnail for webp image files.*/
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable_image_types = array( IMAGETYPE_WEBP );
        $info = @getimagesize( $path );
        if (empty($info)) {
            $result = false;
        } elseif (!in_array($info[2], $displayable_image_types)) {
            $result = false;
        } else {
            $result = true;
    return $result;
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

If you want to see image (thumbnail) preview when you go Media » Library you have to add this code below in the same functions.php file, copy and paste the code below at the end of the file and save it.

Find more Tutorials like this in the Tutorials section.

Leave a Comment

Your email address will not be published. Required fields are marked *

Latest Video

For more videos, visit the channel.

Recent Posts

Please Read

This website totally runs on ads, and it would help alot if you just click on one or two ads whenever you visit this website.
Not asking for any kind of donation, just click on any one of  ads. That would help keeping this website alive.
Thank You
for your support!