Sindu Potha

Sindu Potha was created by us who wish to enjoy Sri Lankan songs.

How To Upload WebP Files on WordPress

How To Upload WebP Files on WordPress - 100% Manual
How To Upload WebP Files on WordPress – 100% Manual

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 files 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 a 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.

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

  • Make faster load your website
  • Make faster load your media files
  • Google “PageSpeed Insights” also recommends WebP files
  • Best user experience
  • And more…

How to upload WebP images directly to WordPress?

This is easy. Just add some text lines 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.

Appearance Theme Editor and find functions
How To Upload WebP Files on WordPress
//** *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 the fastest image view.

Leave a Comment

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

Scroll to Top