magruf

Webp WP

Apr 13th, 2021
498
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'wp_check_filetype_and_ext', 'wpse_file_and_ext_webp', 10, 4 );
  2. function wpse_file_and_ext_webp( $types, $file, $filename, $mimes ) {
  3.     if ( false !== strpos( $filename, '.webp' ) ) {
  4.         $types['ext'] = 'webp';
  5.         $types['type'] = 'image/webp';
  6.     }
  7.  
  8.     return $types;
  9. }
  10. add_filter( 'upload_mimes', 'wpse_mime_types_webp' );
  11. function wpse_mime_types_webp( $mimes ) {
  12.     $mimes['webp'] = 'image/webp';
  13.  
  14.   return $mimes;
  15. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×