What Is A WebP Image?

WebP is a new image format developed by Google employing both lossy and lossless compression.
WebP format is the sister project of WebM video container format—based on the VP8 video codec developed by On2 Technologies—released by Google.
WebP 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 And WordPress

Upon trying to upload a WebP image to a wordpress site, you will be met with an alert such as:

Sorry, this file type is not permitted for security reasons.

This error message is displayed because WordPress does not have native support for WebP files.

The Solution

Adding some basic code to functions.php will rectify this allowing for the use of WebP images with a wordpress installation.
The first part of the code will allow for WebP images to be uploaded to WordPress without previews. If you’d like previews enabled, add the second part of the code also.

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);
Translate »

Enjoy this blog? Please spread the word :)