Optimus

Find answers, guides, and tutorials to optimize your images.

WordPress Media Library JPEG Compression

Updated on November 21, 2018

Add the following code in the functions.php to control the JPEG compression level in the WordPress media library:

<?php

add_filter(
    'jpeg_quality',
    'adjust_jpeg_quality'
);

function adjust_jpeg_quality($quality) {
    return 100; /* 0 = strong compression / 100 = no compression */
}

This setting do not impact the Optimus plugin or the way how Optimus compress your images. Optimus always uses smart compression to optimize JPEG images using slight lossy compression and PNG images using lossless compression. Changing the JPEG quality in WordPress is ideal if you still wish to have a lossy compression to further reduce your thumbnail image size below a 82% quality. The lower the quality factor is, the lower the quality of your JPEGs will be. Read more about Optimize JPEG quality in WordPress.

KeyCDN uses cookies to make its website easier to use. Learn more