How To Upload WebP images in WordPress (Without Plugin)

0
117

What is a WebP image? How to enable WebP images? Is it good to upload WebP images? How to enable WebP images using PHP code? – In this article, I will give all the answers to the questions I was mentioning above so stay tune with this article and read everything very carefully.

What is WebP Image?

WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP format images, webmasters and web developers can create smaller, richer images that make the website faster.

WebP image format file compresses images to 26% smaller in size compared to PNG and 25-34% smaller in size as compared to JPEG image format. This image file format is capable of reducing image file size up to 34% smaller in size retaining high quality. WebP lossless also supports transparency at just 22% additional byte.

Serving Quality images in small bytes means saving your bandwidth in a smarter way. Images play a big role in website speed heavy images mean a slow loading of website so Google has developed a new image format that will help developers to increase their website speed. The various popular sites are already using this image format to boost up their site speed. If you want to boost your site speed then you should use this new image format to get a better result in Ranking.

How To Change The Permalink Structure In WordPress?

How to Add Floating Ads in Blogger Sidebar

How to Enable WebP Uploading in WordPress

There are two ways to allow WebP image upload in WordPress

First Method using Plugin

Step 1: Go to WordPress Dashboard➤ Plugins➤ Add New

Go to WordPress Dashboard➤ Plugins➤ Add New

Step 2: Search Allow WebP or upload Plugins {Download plugin}

Search Allow WebP or {Direct Link}

Step 3: Click on Install and activate this Plugin.

So this is the first and easiest method but if you don’t want to add any plugin then there is a second method where we are going to use code. If you are new to WordPress and don’t know about coding then just follow my step don’t use your brain extra.

Method- 2 (using PHP code) 4 Easy Steps To Upload WebP image files in WordPress without plugin

By default WordPress does not allow you to upload WebP image files, if you want to upload WebP image files to WordPress then follow these 4 easy steps below where I guide you step-by-step with images on how to add to allow WordPress to upload WebP images.

Step 1: Login to your WordPress Dashboard and Go to Appreance➤ Theme Editor.

Login to your WordPress Dashboard and Go to Appreance➤ Theme Editor.

Step 2: Select the Theme Function (functions.php).

Select the Theme Function (functions.php)

Step 3: Now Scroll down at the last line, add this code Given below.

COPY CODE 👇

function webp_upload_mimes( $existing_mimes ) {
	// add webp to the list of mime types
	$existing_mimes['webp'] = 'image/webp';

	// return the array back to the function with our added mime type
	return $existing_mimes;
}
add_filter( 'mime_types', 'webp_upload_mimes' );

//** * 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);
Now Scroll down at the last line, add this code Given below.

Step 4: Then Click on Update File, This will save this code.

So everything is done now you can enjoy uploading WebP images and speed up your site speed.

I Hope guys, You’ll get some useful information from this article, If you like this article, please share this article with those who need it and if you are facing any issues regarding this topic then comment down below I will try to solve your problems.

LEAVE A REPLY

Please enter your comment!
Please enter your name here