
How to Control Image Compression in WordPress
- August 17, 2016
- Leave a comment
By default, WordPress compresses your images for higher efficiency. In this article, you will learn the best way to either enhance or lower JPEG compression in WordPress. Whenever you add a JPEG in WordPress, it will automatically be compressed to 90% high quality.
In WordPress 4.5 version, this quantity is decreased to 82% to enhance website efficiency for cell customers. But, you can turn-off image compression in WordPress any time by using following code:
1 2 3 4 5 |
add_filter('jpeg_quality', 'image_quality_increase'); function image_quality ($arg){ return 100; } |
If your website has too many graphics and you are facing page loading issue, you may want to increase the compression and decrease image quality. Following code can be used to decrease the image quality:
1 2 3 4 5 |
add_filter('jpeg_quality', 'image_quality_decrease'); function image_quality ($arg){ return 75; } |
Do you mean?
add_filter(‘jpeg_quality’, ‘image_quality_increase’);
function image_quality_increase($arg){
return 100;
}
or perhaps even without the quotes – sorry i am php newb
Hello David,
Yes, just add this snippet in your activated theme’s functions.php file and set the image quality value according to your needs. For more details regarding this hook, please read its documentation on WordPress Codex.
Thanks for reaching us out. Let us know if you need any other assistance from us.
Regards,
—
Abdullah | WP Plugin Developer
Email: support@presstigers.com