How to Enable WebP Support in WordPress Media Uploads

WebP_WordPress_Media_ipdata_code

WebP is a modern image format that provides smaller file sizes and faster loading compared to JPEG and PNG. Since WordPress 5.8, WebP is supported natively, but some users still see errors like:

“The web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.”

If you’re facing this issue, here are the steps to fix it.

1. Check if Your Server Supports WebP

WordPress relies on PHP’s GD or Imagick extensions to process WebP images.
Create a PHP file (e.g., gd_info.php) with:

<?php
print_r(gd_info());
?>
  • Look for WebP Support => 1 in the output.

  • If it says 0, your server doesn’t support WebP resizing yet.

2. Enable WebP Uploads Manually [Option 1]

If uploads are blocked, add this snippet to your theme’s functions.php or a custom plugin:

// Allow WebP uploads
function allow_webp_uploads($mimes) {
    $mimes['webp'] = 'image/webp';
    return $mimes;
}
add_filter('upload_mimes', 'allow_webp_uploads');

This allows WordPress to accept WebP files, even if thumbnails can’t be generated.

2. Allow WebP Uploads via Functions.php [Option2]

If uploads are still blocked, add this code to your theme’s functions.php (or use a custom plugin):

// Enable WebP uploads in WordPress
function enable_webp_uploads($mimes) {
    $mimes['webp'] = 'image/webp';
    return $mimes;
}
add_filter('upload_mimes', 'enable_webp_uploads');

// Fix display in Media Library
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable = array('webp');
        $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
        if (in_array($ext, $displayable)) {
            return true;
        }
    }
    return $result;
}
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

3. Install Required PHP Extensions

Ask your hosting provider to enable:

  • GD library with WebP support

  • or Imagick with WebP support

On Linux, these are often installed with:

sudo apt install php-gd
sudo apt install php-imagick

(Your host must do this if you’re on shared hosting).

4. Disable Responsive Image Sizes (Optional)

If you only want to upload WebP without generating thumbnails, you can bypass the error by adding this:

This stops WordPress from generating extra image sizes, but it means no responsive versions of your WebP image will be created.

Conclusion

WordPress supports WebP, but your server configuration decides whether uploads and thumbnails work properly. The best solution is to enable GD/Imagick with WebP on your hosting server. If that’s not possible, you can still upload WebP manually or use a plugin to handle conversions and fallbacks.

Previous Article

FPDF : Table with MultiCells

Next Article

Best Color Layouts and Themes for Student Portal UI / LMS UI [UI Color & Style Guidelines]

Write a Comment

Leave a Comment

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

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨