How To Upload WebP Files on WordPress

1 min


How To Upload WebP Files on WordPress
How To Upload WebP Files on WordPress

How To Upload WebP Files on WordPress?

Are you worried about how to convert your .jpg and .png images to .webp files using a wordpress website? No Cloud, no subscription, no premium fees or accounts needed. You already know you cannot upload Webp file to WordPress media. So today we are going to discuss How To Upload WebP Files on WordPress without using any plugins or paid subscriptions.

WordPress error message when you try to upload Webp file: Sorry, this file type is not permitted for security reasons. If you’ve tried to upload a Webp file to your media library and received the “Sorry, this file type is not permitted for security reasons” error, you may feel stumped as to how to proceed. Below we will explain how to solve the problem.

TechEduTricks.com also uses this trick. Why you need to upload media files in WebP format?

  • Make faster load your website
  • Make faster load your media files
  • Google “PageSpeed Insights” also recommend WebP files
  • Best user experience
  • And more…
How To Upload WebP Files on WordPress
Google "PageSpeed Insights" also recommend WebP files
Google “PageSpeed Insights” also recommend WebP files
How to upload WebP images directly to WordPress?

How to upload WebP images directly to WordPress? 

This is easy. Just add some text line on your theme functions.php file. Log in to your WordPress admin area and go to Appearance > Theme Editor and find functions.php. After that paste the code below at the end of the file and save it.

//** *Enable upload for webp image files.*/
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
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);

Have a good day!! and enjoy fastest image view.


Like it? Share with your friends!

Danushka Sanjeewa
Danushka Sanjeewa is a Software engineer with more than 5 years of experience in Android App Development, Web Development, Marketing, Graphic design, Video editing, and WordPress. And also Writer/Founder of TechEduTricks.com.

0 Comments

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