WordPress functions.php tricks: Disable image compression

WordPress automatically compresses JPEG images at 90% quality. In this article, I will show you how to increase or decrease WordPress JPEG image compression.

All you need to do is paste the following code in your theme’s functions.php file or your site-specific plugin.

add_filter('jpeg_quality', function($arg) {
    return 100;
});
Setting it to 100 would mean that WordPress would compress the image at its highest quality. For most users, this is not an issue. Heck, we never noticed it on our site. But if you are a photographer, then this is noticeable (we suppose).

There are definitely performance benefits to leaving the compression quality as is. If you want, you can change the number from 100 to 80 or something lower to squeeze a few more kBs.

Panagiotis

Written By

Panagiotis (pronounced Panayotis) is a passionate G(r)eek with experience in digital analytics projects and website implementation. Fan of clear and effective processes, automation of tasks and problem-solving technical hacks. Hands-on experience with projects ranging from small to enterprise-level companies, starting from the communication with the customers and ending with the transformation of business requirements to the final deliverable.