Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Change WordPress JPEG Image Compression

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Change WordPress JPEG Image Compression

By default, WordPress compresses your images for better performance. Recently one of our readers asked if it was possible to change the image compression setting in WordPress. In this article, we will show you how to increase or decrease JPEG image compression in WordPress.

Every time you upload a JPEG image in WordPress, it would automatically compress the image to 90% quality. In WordPress 4.5, this number was further decreased to 82% to improve site performance for mobile users.

If you are a photographer who wants to showcase high quality images on your website, then you can turn off image compression in WordPress.

To make it easy, we have created a video tutorial on how to change WordPress JPEG image compression that you can watch below.

However if you just want to follow text-instructions, then you can follow our step by step tutorial on how change WordPress JPEG image compression in WordPress.

How to Disable Image Compression in WordPress

All you need to do is 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 compress the image at its highest quality.

If you’re not a photographer or an artist, then you would probably not see much of a difference in quality. But for those who work with high quality images on a daily basis, the difference in quality is obvious.

How to Increase Image compression in WordPress

There are definitely performance benefits to leaving the compression quality as is. If you want, you can change the number from 100 to 80 or something lower to squeeze a few more kBs, then all you have to do is paste the following code:

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

When you do make these image quality changes, you want to make sure that you regenerate your thumbnails.

We hope this article helped you learn how to change JPEG image compression in WordPress. If you’re a photographer, then you may want to check out Envira Gallery and the supersize add-on that allows you to display full-quality images on fullscreen view.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Lukas Priyambodo says:

    Quality 100 doesn’t always mean highest quality, because of JPEG algorithm and what kind of content of the image. Using SSIM, I sometimes found that quality 95 has better score than quality 100 or at least quality 95 has better filesize trade off compare to quality 100.

  2. Jaime says:

    Hi there. Are you able to disable image compression if you have a free WordPress account? If so, where do I find my function’s php file?

  3. M.Mairaj says:

    Thanks for sharing such a fantastic post about image Compression in WordPress. All the tips are really very very worthwhile.

    Keep sharing :)



  4. Peter says:

    Don’t follow this advice! I added this line of code in my functions.php file and now I get this message when loading my website!

    Parse error: syntax error, unexpected T_STRING in /home/sittin11/public_html/wp-content/themes/Divi/core/functions.php on line 44

  5. blogmann says:

    I’m using plugin Imsanity, it has more settings

  6. karl says:

    Let’s clear up some things.
    1 – WP does not mess with your original uploaded file. The compression levels discussed are for WP generated images – the TN, Med, Large in your WP media settings.

    2 – if you change the compression settings, WP does not reprocess all your current uploads. That’s why you run Regenerate Thumbnails.

    3 – I will challenge any photographer to see the quality difference between 100 and 90 in a JPG. In rare cases, you may. But for 99% of images you’ll never tell.

    4 – Depending on your theme and your media settings, yes, some smaller image sizes will be cropped from your orignal upload. It’s the nature of the beast. If your TN is square and you upload a horizontal phjoto, of course it will be cropped. Cropping your images BEFORE uploading – and using a proportion compatible with your theme layout – will net you fewer issues.

  7. chang hong says:

    hello, can you tellme why wp crop every image that i upload? how can i prevent it! thank you

  8. Dave Porter says:

    Thanks for the article, very useful to know.

    I’m interested in the comment about ‘make sure you regenerate your thumbnails’

    If an image is uploaded at say 82%, regenerating the thumbnails does what?

    And I assume that after changing the percentage, this is only going to be for new images?
    I would guess any existing images would remain at the same quality, or does WordPress keep a copy of the original uploaded?
    TIA, Dave

  9. Michael says:

    Is it possible to disable image compression in WordPress?
    The article has a headline saying so, but then it describes it as “least compression”, that is not disabling compression…just wondering it is possible to disable compression for uploaded pictures…

  10. Thomas says:

    Great Tips, thank you.
    I have one more question: If I upload images to WP that are already compressed (say to 90%) – will they be compressed again (82% of 90% = 74.8%)?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.