How to stop WordPress from compressing JPG image files without using a plugin

WordPress by default compresses uploaded JPG files to 90% of their original quality. While the reasoning behind this is to save your hosting bandwidth, it can however result in less than desired image quality. If image quality is more of concern than bandwidth and you prefer to avoid installing unnecessary plugins, you can simply reset the image compression back to 100% by adding 2 lines of code to your functions.php file. In this tutorial we will teach you how to stop WordPress from compressing JPG image files by using PHP filters instead of a plugin.

Stop WordPress from compressing JPG files by using 2 PHP filters

In order to stop WordPress from compressing JPG files, we will add the following 2 PHP filters to the WordPress functions file. Simply open your functions.php file, then copy and paste the code below.


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


If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.