How to configure or disable WordPress JPEG image compression

By default, WordPress compress uploaded jpg images. This can be a good thing because it makes the filesize smaller (not the dimension), but in some case, image quality can be more important than filesize. If you need to prevent WordPress from compressing your images or you wish to specify what level of compression WordPress should apply, simply add this snippet.

Instructions
Add this code to your functions.php file.

Comments

4 Replies to “How to configure or disable WordPress JPEG image compression”

  1. Hi, thanks for the advice! I’m a bit lost because of conflicting info about which code to use to disable image compression and its relevance to the current WordPress version. I understand the advice in this article was written during 2012, which is about 6 years ago, so I’m wondering if the code this article recommends will still work in the current WordPress version.

    Also, can you please explain the difference between the code recommended in this post compared with the code versions below?

    Thanks so much for any advice you can give!

    Code 1
    add_filter(‘jpeg_quality’, function($arg){return 100;});

    Code 2
    add_filter( ‘jpeg_quality’, create_function( ”, ‘return 100;’ ) );

    Code 3
    add_filter(‘jpeg_quality’, function($arg){return 100;});
    add_filter( ‘wp_editor_set_quality’, function($arg){return 100;} );

Leave a Reply

Your email address will not be published. Required fields are marked *

Siteground Web Hosting