Created
July 10, 2020 13:33
-
-
Save davidchc/f6372d6909b3ab346f31ab4898e9a30c to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
function add_file_and_ext_webp( $types, $file, $filename, $mimes ) { | |
if ( false !== strpos( $filename, '.webp' ) ) { | |
$types['ext'] = 'webp'; | |
$types['type'] = 'image/webp'; | |
} | |
return $types; | |
} | |
add_filter( 'wp_check_filetype_and_ext', 'add_file_and_ext_webp', 10, 4 ); | |
function add_mime_types_webp( $mimes ) { | |
$mimes['webp'] = 'image/webp'; | |
return $mimes; | |
} | |
add_filter( 'upload_mimes', 'add_mime_types_webp' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment