Easy Steps To Upload webP images To WordPress

Are you worried about how to upload WebP images to WordPress and how to convert your JPG and PNG images files to WebP files? Then you are in the right place, Today I will give you a solution to these problems. After reading this article you will be able to add WebP image on your WordPress website without installing any plugin.

Recently, Google has introduced a new image file format called WebP. WebP is a next-generation image file format, It compresses image files up to 34% smaller in size without losing any quality. Google recommends to use this file format to increase your website speed, But the problem is we are unable to up-load webp image file to WordPress and many of us are using WordPress. Here is the solution to upload webp image file to WordPress.

How To Upload WebP Images To WordPress

When you try to upload WebP image file format to your WordPress website, It shows you an error message ”Sorry, this file type is not permitted for security reasons”. If you have tried to upload a WebP file to your WordPress media library and you receive the error message “Sorry, this file type is not permitted for security reasons“, I will explain it here, how to upload webp image files to your WordPress website. If you face any problem you can take the help of this video.

WordPress shows you this error because WordPress does not natively support viewing and uploading WebP files, your hosting provider doesn’t recognise this file type so they don’t allow you to upload. First, you have to inform your hosting provider about this file.

Also Read-: What is WebP image Format | Google Next-Gen Image Format

How about directly uploading WebP images to WordPress? It’s very easy, you have to add some code on your theme functions.php file, Just follow these steps below

6 Easy Steps To Upload Webp image files to WordPress

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 steps below.

  1. Log in to your WordPress admin area
  2. Appearance
  3. Theme Editor
  4. Theme Functions [ functions.php]
  5. Copy and Paste this below-given Code and click on update file
  6. You are done, now you will be upload WebP files to your WordPress website
How To upload WebP format image to wordpress

Add this below given code to your theme functions (functions.php)

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

After adding this code you will be upload WebP images to your WordPress but you can’t preview these images on your media library. If you want to see an image preview of these files on your media library you have to add some extra code to your Theme Functions (functions.php) of your WordPress Theme, The code is given below.

Add the below given code to your theme functions (functions.php) to preview webp images on your media library

//** * 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 Convert JPG and PNG To WebP Format

I think I have solved your query ‘how to upload webp images to WordPress. WebP image file format is natively supported by Chrome, Edge, Firefox and many other web browsers. Here I will explain to you how to convert a JPG or PNG format image to WebP format, to do that you should have some converter software. If you want to convert your images to WebP format online for free, then you can visit some website they provide online image converter for free. I have listed some website name that I use to convert my images, you may use these websites or others to convert your images.

How WebP Images Will Impact Your Website SEO?

In this article, I have explained to you how to upload webp images to WordPress and how to convert an image file to webp file. You should know what is the profit of using webp image file on our website, definitely, there are many profits of using this new image file format. Firstly, this is a next-generation image file format and this is developed by Google. PageSpeed Insight also recommends using this image file type, After using this images file type your website speed will increase definitely which will help you in the Google ranking.

I hope this helped you to upload webp image files on WordPress, please do share this on your social media. Join with me on Facebook, Twitter, YouTube and Instagram.

Hey, I am Keshab Chandra Behera an Indian Blogger, Affiliate Marketer and YouTube Personality based in Bhubaneswar, Odisha, India.

Leave a Comment