Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Created October 6, 2017 18:03
Show Gist options
  • Save EricBusch/ebd2dd6c48a8803f686d0bcda439c8f7 to your computer and use it in GitHub Desktop.
Save EricBusch/ebd2dd6c48a8803f686d0bcda439c8f7 to your computer and use it in GitHub Desktop.
This adds support for webp when importing webp images into WordPress. [datafeedr]
<?php
/**
* Add support for webp to WordPress.
*
* @param array $mime_types
*
* @return array Updated $mime_types array.
*/
add_filter( 'mime_types', 'mycode_mime_types', 20 );
function mycode_mime_types( $mime_types ) {
if ( isset( $mime_types['webp'] ) ) {
return $mime_types;
}
$mime_types['webp'] = 'image/webp';
return $mime_types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment