How to stop WordPress from compressing your uploaded jpeg images

Stop WordPress Compressing Your JPEGs, FixMyWP guide header image

The WordPress Media Library is a powerful tool for managing and displaying images on your website. So, does WordPress automatically compress images? Yes. When you upload a JPEG, WordPress keeps your original file but creates resized copies (thumbnail, medium, large and any sizes your theme adds) and saves them at 82% quality, the default since WordPress 4.5 (it was 90% before that). Since WordPress 5.3, images wider or taller than 2560 pixels also get a scaled-down “-scaled” copy, which is used in place of the original on your pages. This keeps file sizes small so pages load faster, but it may not always be ideal, especially for websites focused on selling or showcasing high-quality images. Fortunately, there are several ways to stop WordPress compressing images, or disable image compression completely, and keep the image quality you need.

Embrace PNG Images

One of the quickest and most effective workarounds is to utilize PNG images instead of JPEGs. Unlike JPEG, PNG is a lossless compression file format, meaning it retains the original image quality without sacrificing details or introducing artifacts. This makes PNG ideal for displaying line drawings, text, and iconic graphics at a small file size. By opting for PNG, you can ensure that your images appear crisp and vibrant, making it an excellent choice for designer websites or photography portfolios. Keep in mind that photos saved as PNG are usually much larger than JPEGs, which can slow down your site speed, so use PNG mainly for graphics and screenshots. WordPress also supports WebP uploads (since version 5.8) and AVIF (since 6.5), which give smaller files at high quality.

Code Modification in the Theme’s functions.php

For those comfortable with making code modifications, another option is to edit your theme’s functions.php file (ideally in a child theme, so a theme update does not remove your change). By adding two simple lines of code, you can override the default JPEG compression settings and set it to 100%, effectively preserving the original image quality. The following code snippets can be added to your theme’s functions.php file:

Need a hand with your WordPress site? Answer four quick questions and see your flat price before you pay. Start here →

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

Once saved, WordPress will no longer compress the resized JPEG images it creates, so they keep their full quality and visual appeal. This only applies to new uploads. To update images you have already uploaded, regenerate their thumbnails, for example with the WP-CLI command wp media regenerate.

If you also want WordPress to stop creating “-scaled” copies of large images, add this line as well:

				
					add_filter( 'big_image_size_threshold', '__return_false' );
				
			

If you prefer not to edit theme files, you can add the same snippets with a code snippets plugin such as WPCode.

Plugin Solution for Controlling JPEG Compression

For users who prefer not to modify theme files directly, a convenient plugin called WP Resized Image Quality can provide granular control over the compression level of all uploaded JPEG files. This plugin allows you to specify the desired compression rate for both full-sized images and their thumbnails. By adjusting the settings to your preference, you can strike a balance between image quality and file size, achieving the optimal visual experience for your website visitors. Before you install it, check its WordPress.org page to make sure it is still maintained and tested with your version of WordPress.

While WordPress compresses uploaded JPEG images by default to keep file sizes and page load times down, this may not always be desirable, especially for websites that rely heavily on image quality. By implementing one of the mentioned workarounds, such as using PNG images, modifying the functions.php file, or utilizing a specialized plugin, you can ensure that your website presents high-quality images, catering to the needs of design-oriented or photography-focused websites. By optimizing image quality, you can enhance the visual appeal and user experience of your WordPress site while still maintaining control over file sizes and website performance.

★★★★★
I highly recommend hiring FixMyWP to fix your website. They are very professional and my issues were resolved within a few hours.
Nico Timmermans
spyglassrockband.com
Cover of the free WordPress Optimization Guide from LeDetailWP

Free guide from LeDetailWP

WordPress Optimization Guide

Optimization steps you can finish in about an hour to make your WordPress site faster. No tech jargon.

Get the free guide →

Need a hand with your WordPress site?

Answer four quick questions and see your flat price before you pay. Most fixes are done the same day or within 24 business hours.

Answer 4 quick questionsSee all prices

In this article

Need a hand with your site?

Answer four quick questions and see your flat price before you pay. Most fixes are done the same day or within 24 business hours.

Related articles