How to change WordPress image compression

By default WordPress compresses the uploaded JPEG images and JPG images to 85%. Before WordPress 4.5 uploaded JPEG images were compressed to 90%. The compression was further increased to improve site performance for mobile users. WordPress will not compress the original uploaded image, only the generated images like large, medium, thumbnail and custom sizes.

If you want full image quality on your website (because for example you are a photographer) you want to turn off image compression in WordPress.

How to disable image compression in WordPress

You have to paste the following code in your theme’s functions.php file or in a site-specific plugin.
add_filter( 'jpeg_quality', function( $arg ) { return 100; } );
When you set the value to 100, it means that WordPress will keep the image at its highest quality.

How to increase image compression in WordPress

Compressing your images more than the default will boost your site’s speed and performance because the images will have a smaller file size. Most people will not notice the quality difference between 90% or 75%, but it will save you some extra bandwith and loading time.
add_filter( 'jpeg_quality', function( $arg ) { return 75; } );

After changing the compression ratio of your images it will only be applied to newly uploaded images. If you also want it to be applied to existing images you have to regenerate the thumbnails.

Leave a Reply

Leave a Reply about "How to change WordPress image compression". Your email adress will not be published. Required fields are marked *