Envira Gallery Blog

Digital Photography Tips, Tutorials and Resources

WordPress Image Compression

How to Get Around the New WordPress Image Compression Settings

by Waseem Abbas on Jun 10, 2016

Want to know how to get around the default image compression settings in WordPress? When WordPress 4.5 was released, the compression setting was changed from 90 to 82, resulting in lower file sizes (and lower quality). In this article, we will share how to get around the new WordPress image compression settings.

Changes to WordPress Image Compression

In WordPress 4.5, there is a major decrease in the file size of photos resized by WordPress.

By default, WordPress now compresses images to 82% for increased page load speed, especially on mobile devices. Better performance is a good thing, but it can also be a bad thing if your images come out looking lower quality than you want. (You can learn about the compression changes here.)

If you are concerned about page speed and your image quality, we recommend that you check out these image optimization tools for image compression so that you have more control over how much or how little your images are compressed.

We should note that you can avoid the WordPress image compression settings simply by editing your photos in Photoshop before uploading them to WordPress. However, you may enjoy the convenience of editing your photos directly inside WordPress, and you may not want to install yet another plugin to do the job.

In that case, we have a simple solution for you.

Let’s get into the steps of how to get around the new WordPress image compression settings…

How to Disable WordPress Image Compression

If you want to completely retain the quality of your images after resizing them in WordPress, you can simply disable image compression.

To disable it, you’ll need to add the below code into the function.php file of your theme:

add_filter('jpeg_quality', function($arg){return 100;});

The ‘return’ value of 100 ensures that WordPress will keep the original quality of the image.

How to Decrease or Increase Image Compression in WordPress

If you want to keep some amount of compression, you can simply reduce the return value. To go back to the way WordPress was before version 4.5, set the return value to 90:

add_filter('jpeg_quality', function($arg){return 90;});

Or, you can set the return value to 75 and increase the compression even more:

add_filter('jpeg_quality', function($arg){return 75;});

After inserting this code into your function.php file, you’ll need to regenerate your thumbnails before you will see the effect of your custom WordPress image compression settings. (You can easily regenerate thumbnails with the Regenerate Thumbnails plugin.)

We hope this article has helped you to learn how to get around the new WordPress image compression settings. You may also want to check out our guide on how to add fullscreen image galleries in WordPress.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Comments

  1. Very useful article, I’m going to add galleries to my blog but concerned about images size, now i will do some compression.
    Thanks.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

[i]
[i]
[i]
[i]