DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

By default, WordPress compress uploaded jpg images. This is a good thing because it makes the files smaller, but in some case, image quality can be more important. If you need to prevent WordPress to compress your images, simply apply this simple tip.

Open your functions.php file and paste the code below in it:

add_filter('jpeg_quality', function($arg){return 100;});

Save the file, and you’re done. That’s simple as that!

Thanks to WP Snippets for the tip!



  1. Hello
    I let you check this page :
    The callback can not be a function … Testing before posting is more pro.

  2. Julio: Reading the full documentation you link to is even more pro; it says, “You can also pass the callback paramater as an anonymous function,” which is what the code given above does.

  3. Can it work in PHP 5.2.4 (WP min requirements at this time ?)
    Because PHP manual says that anonymous functions work only from PHP 5.3.

  4. Also, this code will only work with PHP 5.3 or newer. WordPress works with older versions, so a disclaimer that this code may cause errors on certain installations may be in order.

    Here’s a more compatible snippet:

    add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );

    100 can, of course, be changed to any valid percentage. Changing it to 1 results in some interesting, lo-fi uploads.

  5. Just drop images into ImageOptim instead?

Leave a Comment

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