Every time you upload an image file to WordPress, an automatic lossy compression is applied for better performance and improve site performance for mobile users. What if you want to change the JPEG compression level used by default?
Below is the code to increase or decrease the JPEG compression level of the next image files you upload to WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Prevent JPEG compression | |
add_filter('jpeg_quality', function($arg){return 100;}); | |
//* JPEG compression level set to 75% | |
add_filter('jpeg_quality', function($arg){return 75;}); |
Alternatively, you can download, install and set up WP Resized Image Quality from the WordPress Plugin Repository.