Changeset 50810 for trunk/src/wp-includes/functions.php
- Timestamp:
- 05/04/2021 02:43:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r50505 r50810 2887 2887 'image/bmp' => 'bmp', 2888 2888 'image/tiff' => 'tif', 2889 'image/webp' => 'webp', 2889 2890 ) 2890 2891 ); … … 3064 3065 $mime = false; 3065 3066 } 3067 3068 if ( false !== $mime ) { 3069 return $mime; 3070 } 3071 3072 $handle = fopen( $file, 'rb' ); 3073 if ( false === $handle ) { 3074 return false; 3075 } 3076 3077 $magic = fread( $handle, 12 ); 3078 if ( false === $magic ) { 3079 return false; 3080 } 3081 3082 // Add WebP fallback detection when image library doesn't support WebP. 3083 // Note: detection values come from LibWebP, see 3084 // https://github.com/webmproject/libwebp/blob/master/imageio/image_dec.c#L30 3085 $magic = bin2hex( $magic ); 3086 if ( 3087 // RIFF. 3088 ( 0 === strpos( $magic, '52494646' ) ) && 3089 // WEBP. 3090 ( 16 === strpos( $magic, '57454250' ) ) 3091 ) { 3092 $mime = 'image/webp'; 3093 } 3094 3095 fclose( $handle ); 3066 3096 } catch ( Exception $e ) { 3067 3097 $mime = false; … … 3102 3132 'bmp' => 'image/bmp', 3103 3133 'tiff|tif' => 'image/tiff', 3134 'webp' => 'image/webp', 3104 3135 'ico' => 'image/x-icon', 3105 3136 'heic' => 'image/heic', … … 3223 3254 'ext2type', 3224 3255 array( 3225 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic' ),3256 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'heic', 'webp' ), 3226 3257 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 3227 3258 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ),
Note: See TracChangeset
for help on using the changeset viewer.