How to Upload WEBP images in WordPress (Without Any Plugins)

4
2329

Go To Appearnace>Theme editor> Functions.php> Paste the code at the bottom and 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);

4 COMMENTS

  1. THANKS BRO..

    AGAR wordpress post articles CONTENT 2000 ke upar ka hai to heading kaise aur kitane dene ke …. pls guide. thanks ..

  2. hello sir ,
    you created this website in previous month.
    After how many days techripon website got adsense approval.
    And after how many days ,and how many posts on site when you apply for adsense.
    please help me sir ,you are a big motivation for us.

  3. Bro Error Comming in Line 475 Linkha aa Rha h… Techreveals.in site h… And Adsense m bhi help kro please, mil hi ne rha…

LEAVE A REPLY

Please rate
Please enter your comment!
Please enter your name here