How to Upload WEBP images in WordPress Without Any Plugins

Upload WEBP images in WordPress
5/5 - (7 votes)

Hello, guys in this article I will show you how to upload WEBP images in WordPress without any Plugins.

Follow these steps:

  • Go To Appearance
  • Open Theme editor
  • Click on Functions.php
  • Paste the code at the bottom
  • Save the file.
function webp_upload_mimes( $existing_mimes ) {
 // add webp to the list of mime types
 $existing_mimes['webp'] = 'image/webp';
 // return the array back to the function with our added mime type
 return $existing_mimes;
 }
 add_filter( 'mime_types', 'webp_upload_mimes' );
 //** * Enable preview / thumbnail for webp image files.*/
 function webp_is_displayable($result, $path) {
 if ($result === false) {
 $displayable_image_types = array( IMAGETYPE_WEBP );
 $info = @getimagesize( $path );
 if (empty($info)) {
 $result = false;
 } elseif (!in_array($info[2], $displayable_image_types)) {
 $result = false;
 } else {
 $result = true;
 }
 }
 return $result;
 }
 add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

 

Leave a Reply

Your email address will not be published. Required fields are marked *