How To Upload WebP images in WordPress {Without Plugin}

Sorry, this type is not permitted for security reasons, solve upload WebP images in WordPress, I give you a solution to these problems after read you will be able to upload WebP images in WordPress website without installing any plugin which is very simple, and you just needed to do only one time.

WEBP image now upload wordpress solved

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 35% smaller in size without losing any quality.

How To Upload webP images in WordPress Without Plugin

Easy Steps To Upload WebP image files in WordPress without plugin

WordPress does not allow you to upload WebP image files, if you want to upload WebP image files to WordPress then follow these easy steps

Step 1 – Open Theme Editor In Appearance

Open Theme Editor In Appearance

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

Select the Theme Function

Step 3: Now Scroll down at last line, add this 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);

Not forget to update functions.php file, this will save this code.

I hope you finds this article was helpful. Let us know your comments and ideas for creating Upload webP images in WordPress without plugin.

Other Popular Articles...

Leave a Comment