How to Change WordPress JPEG Image Compression

WordPressPosted on

1 min read

Currently the WordPress JPEG image compression is 82% (from version 4.5) of the original size; this is a needed, but still, there are cases when we want to modify it.

On the web, the image crushing is a critical area because the most significant bloat comes from the uncompressed and unsized images.

How to Turn Off The JPEG Shrinking

To turn off the default settings add the following snippet into your theme – of into your plugin’s files – funtions.php:

function pine_jpeg_quality() {
    return 100;
}

add_filter( 'jpeg_quality', 'pine_jpeg_quality' );
Note that disabling the compression is not a great solution because of the overall performance. Always use some solution like the native or a plugin (TinyPNG, Jetpack’s Site Accelerator).

How to Increase The JPEG Compression

To achieve more performance benefit, we can set the quality to 70 which is more extreme but still quite pleasant for the viewer.

function pine_jpeg_quality() {
    return 70;
}

add_filter( 'jpeg_quality', 'pine_jpeg_quality' );

Need a web developer? Maybe we can help, get in touch!

Similar Posts

More content in WordPress category