Skip to content

Instantly share code, notes, and snippets.

@kabbo508
Last active December 30, 2020 22:29
Show Gist options
  • Save kabbo508/5163c82b5de0dfee509dd8b2d5126da5 to your computer and use it in GitHub Desktop.
Save kabbo508/5163c82b5de0dfee509dd8b2d5126da5 to your computer and use it in GitHub Desktop.
//** * 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment