How To Set Up Webp Images In WordPress.

So, WebP is the new cool. With arguably the best compression of Images available yet, It helps your website execute images quicker and serves faster pages to your online readers. It has better performances than Img, Jpeg, Jpg, PNG. Today I will teach you How To Set Up Webp Images In WordPress.

How To Set Up Webp Images In WordPress.

I recommend that you see this video on How To Set Up Webp Images In WordPress or continue reading the article.

According to Google Developer

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.

WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.

Lossless WebP supports transparency (also known as alpha channel) at the cost of just 22% additional bytes. For cases when lossy RGB compression is acceptable, lossy WebP also supports transparency, typically providing 3× smaller file sizes than PNG.

Set Up Webp Images In WordPress

So without further talk, let us get to it.

Let us assume you have gotten your WebP images ready, and you have tried to upload them in your WordPress. How To Set Up Webp Images In WordPress should not be an issue.

WordPress error message when you try to upload Webp file: Sorry, this file type is not permitted for security reasons. If you’ve tried to upload a Webp file to your media library and you get this error message “Sorry, this file type is not permitted for security reasons” error, you may feel stumped as to how to proceed. Below I will explain how to solve the problem.

Let us solve this problem; You have to edit your theme Function.php file of your WordPress. To do this, Go to Appearance and click on Theme Editor. 

On the right-hand side, click on the Function.php.

How To Set Up Webp Images In WordPress.

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

If you want to see the image (thumbnail) preview when you go to Media / Library, you have to add this code below in the same functions.php file. Where can you find the functions.php file? Go to Appearance / Theme Editor and find functions.php, after which 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);
How To Set Up Webp Images In WordPress.

This message is about WebP. WebP (or WebP), like many other image formats, can provide a discretional lossless and lossy compression for images on the web. There’s “WebP,” a new format that lets webmasters and web developers create smaller, richer images that make the web speedier. The size of lossless WebP images is 26% smaller compared to lossy PNG. Lossy WebP images on the Web are 25-34 percent smaller than comparable JPEG files on the Web at a similar quality index. WebP is natively supported in Google Chrome, Firefox, Google’s Chrome browser, and Microsoft Edge. Some software libraries and software support it too. As well as adding support to a variety of image and photo editing tools.

Safari Desktop and Safari iOS browsers do not support WebP image files. But Who cares? If Apple wants to be unique, then it should stay distinctive. The majority of the web’s content creators have ‘decided’ to move on to a convenient correspondence format.

At the time of writing this post, 84.33% of the global population uses a browser that supports WebP images. Even with this majority fully committing to WebP, that would leave 15.67% of users missing out on WebP format images altogether.

 How To Set Up Webp Images In WordPress.

So you have just learned How To Set Up Webp Images In WordPress. If you have any issues, leave a comment.