Images in webp format
-
Hi All!
Why does WordPress refuse to include webp images support out of the box?
Now I use the following solution:
add mime typeadd_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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Images in webp format’ is closed to new replies.