• Hi All!

    Why does WordPress refuse to include webp images support out of the box?

    Now I use the following solution:
    add mime type

    add_filter( 'upload_mimes', 'valphoto_mime_types', 1, 1 );
    function valphoto_mime_types( $mime_types ) {
      $mime_types['webp'] = 'image/webp';     // Adding .webp extension
      return $mime_types;
    }

    display image thumbnails in media library

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

    The solution works, but has limitations: the php version must be higher than 7.1 (a constant IMAGETYPE_WEBP has been added in this version.)

    How to carry out normal work with webp format on sites with the version of php, for example 5.6 or 7.0?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I use a plugin called WebP Express. It’s awesome and does all the hard work for me. I recommend it. Just be sure all your image dimensions for your theme are registered.

    A great plugin which will handle that for you is called Regenerate Thumbnails. You don’t have to run it, I just install it and let it sit there. It’ll detect all the image dimensions my site uses and when I upload new files it’ll create all the sizes for me so everything looks awesome all the time.

    Thread Starter valery2016

    (@valery2016)

    Hi Gerry!
    Thanks for your reply!

    Just one question … Do you think support for webp in WordPress core is not needed?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Images in webp format’ is closed to new replies.