Created
January 7, 2021 10:18
-
-
Save mbrughi/55622fc651f4433b84eb1a3bb9702f48 to your computer and use it in GitHub Desktop.
Wordpress: enable preview of .webp image files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Enable preview / thumbnail for webp image files. | |
| function display_webp($result, $path) { | |
| if ($result === false) { | |
| $webp_image_types = array( IMAGETYPE_WEBP ); | |
| $info = @getimagesize( $path ); | |
| if (empty($info)) { | |
| $result = false; | |
| } elseif (!in_array($info[2], $webp_image_types)) { | |
| $result = false; | |
| } else { | |
| $result = true; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment