Whenever you upload a JPEG image into WordPress, it automatically compresses the image quality.
If you’re a photographer using WordPress as a portfolio website, or a graphic designer for that matter, you may not want WordPress compressing your image or you may want to do the compression yourself and keep WordPress’ hands off the image altogether.
On the flip side of that coin, WordPress’ 90% image compression default could be dialed down a little, thus, saving some bandwidth and increasing site speed.
No matter your reason for changing the WordPress JPEG image compression setting, here’s how:
How to Prevent (or Reduce) WordPress’ JPEG Image Compression
You can drop this line of code in your theme’s functions.php file or drop it in a functionality plugin:
[cc lang=”php”]add_filter(‘jpeg_quality’, function($arg){return 100;});[/cc]
Easy, right?
Obviously, you could increase it to 95%, 98%, etc … by adjusting it from 100% — ‘100’.
How to Increase WordPress’ JPEG Image Compression
This is essentially the same, you’re just adjusting the {return} numeral. Just like preventing or reducing, this snippet is placed in your functions.php file or your functionality plugin:
[cc lang=”php”]add_filter(‘jpeg_quality’, function($arg){return 60;});[/cc]
Just as before, you can adjust this value accordingly … 75, 70, etc …
That’s it!
[via WP LifeGuard]
Charles Specht says
interesting…
Eric Dye says
Cool …
Pete says
For some reason it makes my entire website, both front and back end, go completely blank?
Katrina says
Hi, I added this in, now I have no blog! can you help?
Eric Dye says
Where did you add this snippet?