How To Upload webp Images In WordPress

How about directly uploading WebP images to WordPress? This is easy and simple step as follow

  1. Go To functions.php in Appearance / Theme Editor and find functions.php
  2. Edit functions.php file
  3. copy below code and paste at the end of the file and save it.
//** *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');

f you want to see image (thumbnail) preview when you go 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 under Theme Editor and edit 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);

Thanks for Reading in Facts Articles Site

Leave a Reply

Your email address will not be published. Required fields are marked *