How to Disable Image Compression in WordPress

By ThemesDNA1 min read

Share:

Have you noticed the blurred appearance of the images you have uploaded to your WordPress website? When you upload images to the media library, WordPress automatically compresses them for better performance. If you are a webmaster who wants to display high-quality images on your website, you can disable image compression in WordPress.

You can disable image compression in WordPress by adding the below code to your theme's functions.php file:

function themesdna_disable_image_compression() {
    add_filter('jpeg_quality', function($arg){return 100;});
    add_filter('wp_editor_set_quality', function($arg){return 100;});
}
add_action('init', 'themesdna_disable_image_compression');

The above code will turn off JPEG compression on your website. 100 indicates that there is no compression. The lower the number, the greater the compression.

Note: Images you have already uploaded will not be impacted by this modification.

Premium WordPress themes Made for WordPress   /   Ready for your story

Ready to Build?

Your next great website starts here.

Build more websites with one flexible collection—and keep every theme for life.

  • 56+ themes
  • Lifetime updates
  • Unlimited websites
  • No renewals

The complete collection

$75

One payment. No renewals.

Get the Themes Bundle — $75