Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

How to Remove WordPress Image Compression

Would you like to remove the default image compression that WordPress applies to your uploaded images? WordPress automatically applies image compression to each image uploaded to your site. This tutorial will walk you through how to turn off image compression with the use of a plugin we will create.

This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to remove image compression, we’ll need to create and upload a basic WordPress plugin.

Creating the Plugin

To remove WordPress Image Compression, just add the following code to a new file at wp-content/plugins/envira-remove-wordpress-image-compression.php.

* Plugin Name: Envira Gallery - Remove WordPress Image Compression
* Plugin URI: https://enviragallery.com
* Version: 1.0
* Author: Envira Gallery Team
* Author URI: https://enviragallery.com
* Description: This will remove the compression WordPress applies to images when uploading to your media library
* Override the default image quality when resizing and cropping images
add_filter('jpeg_quality', function($arg){return 100;});

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown above into the file and save the file as envira-remove-wordpress-image-compression.php.
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Activate the Plugin

Your next step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Envira Gallery – Remove WordPress Image Compression plugin.

Activate the plugin to remove the WordPress Image Compression

After activating, any new image uploaded will no longer be subject to WordPress’ image compression!

Note: any image that was previously uploaded to activating this plugin will need to be re-uploaded to have the compression removed.

That’s it! Would you like to extend Envira further? Check out our tutorial on how to Remove Fragment Cache from Envira Gallery.