WordPress JPEG Quality Filter
Set the quality WordPress uses for the JPEG sizes it makes
Runs in your browser. Nothing is uploaded.
About the WordPress JPEG Quality Filter
Make the PHP filter that sets the JPEG quality WordPress saves its image sizes at (82 by default), for all files or large ones only, with a live preview.
When you upload a JPEG, WordPress writes each image size, and the -scaled copy of a big upload, as a new JPEG at quality 82. Your original upload is kept as it is. This tool writes the PHP filter that changes that number, either for every file or only for the larger ones, and the preview shows what the chosen quality does to a test pattern of flat colours and hard edges, the kind of image JPEG handles worst.
Worked example: quality 90 for the large files only
Settings
Quality: 90
Higher quality for large files only: ticked Generated functions.php code
<?php
/**
* Generated at odiethemes.com/tools/wordpress-jpeg-quality
*
* WordPress saves every JPEG size it makes (and the -scaled copy of a big
* upload) at quality 82 by default. Your original upload is kept as it is.
*/
// Quality 90 for JPEG files with a long edge of 1024 px or more. On a big
// landscape photo: large, 1536x1536, 2048x2048 and -scaled. Smaller sizes keep the default.
// $size is the file being written; WordPress passes it since 6.8.
add_filter( 'wp_editor_set_quality', function ( $quality, $mime_type, $size = array() ) {
$long_edge = max( (int) ( $size['width'] ?? 0 ), (int) ( $size['height'] ?? 0 ) );
if ( 'image/jpeg' === $mime_type && $long_edge >= 1024 ) {
return 90;
}
return $quality;
}, 10, 3 ); - wp_editor_set_quality is the filter WordPress runs each time its image editor sets a quality. The callback takes three arguments, so the add_filter call ends with
10, 3. Without the 3, WordPress would pass only the first one and PHP would stop with an error. $sizeholds the width and height of the file about to be written. WordPress passes it since version 6.8. The= array()default and the?? 0keep the code from failing when it is missing.- The long edge is the larger of width and height, so a portrait's 768 × 1024 large size counts as large. Testing the width alone would have left it at 82.
- Only JPEG files at or above 1024 px get 90. Anything else returns
$qualityunchanged, which is 82 for JPEG.
We tested this on WordPress 7.1.4 (PHP 8.3.36, GD 2.3.3, WordPress Playground) on 2026-11-16 and read the quality back from each file. A 3000 × 4000 portrait, run with the long-edge code above, got 90 for its 768 × 1024 large file and the bigger sizes, and 82 for thumbnail and medium. A 4000 × 3000 landscape was run with a variant that tested the width only, which gives the same result for a landscape photo: 82 for the 150, 300 and 768 px sizes and 90 for large, 1536x1536, 2048x2048 and the 2560 × 1920 -scaled copy.
All files or large files only
With "Higher quality for large files only" unticked, the tool writes a jpeg_quality filter instead. For JPEG files, WordPress applies jpeg_quality after wp_editor_set_quality, so its number is the one that sticks, and in our test every file came out at the chosen quality. The large-only option keeps the thumbnail, medium and medium_large files at the default and raises quality only for the files a page shows big, so the extra disk space goes where it can be seen. The jpeg_quality entry in our hooks reference lists the arguments of the filter.
How to use it
- Pick a quality with the slider and watch the edges in the preview.
- Paste the code into a child theme's functions.php or a small plugin, so a theme update does not remove it.
- Upload an image and compare file sizes in the uploads folder. Higher quality makes every affected file bigger.
The filter changes files WordPress writes from then on. Images already in the media library keep their current files. Regenerating thumbnails rewrites the sizes from the originals, so they should pick up the new quality; we read that from the WordPress 7.1.4 source and did not test it.
Sources
- WordPress Code Reference: jpeg_quality hook
- WordPress Code Reference: wp_editor_set_quality hook
- WordPress Code Reference: WP_Image_Editor::set_quality()
- WordPress Code Reference: WP_Image_Editor::get_default_quality()
- WP-CLI Commands: wp media regenerate
Limits
- Only JPEG. WebP sizes are saved at 86 by default, and this code leaves them alone.
- Our test used GD. Under Imagick, the WordPress 7.1.4 source suggests the cropped thumbnail keeps the quality worked out for the original upload, so with the large-only option it could come out at 90. We read that from the source and did not test it.
- WordPress 7.1 can resize images in the browser for uploads made in the block editor on HTTPS sites and on localhost. We have not tested whether these filters reach that path.
- The preview uses your browser's JPEG encoder. GD and Imagick produce different files at the same number.
Guides for this tool
- Stop WordPress Compressing Your Images at 82%
Raise the WordPress JPEG quality default of 82 with one filter, regenerate the thumbnails already stuck at 82, and know when PNG is the better fix.
- Why WordPress Images Look Blurry After Upload, and the Fix
Blurry after upload? Check whether WordPress capped the file at 2560px or served a too-small size, then fix it. Includes a regenerate test on WordPress 7.1.4.
Related
Other tools you might need
FAQ
Questions
What JPEG quality does WordPress use by default?
82. WordPress saves every size it makes from a JPEG at quality 82, and the -scaled copy of a big upload too. We read the quality back from the files WordPress 7.1.4 wrote on PHP 8.3 with GD (WordPress Playground, 2026-11-16), and all of them were at 82. Your original upload is kept as it is. For WebP the default is 86 (read from the WordPress 7.1.4 source; we did not test WebP).
Should I set JPEG quality to 100?
Usually not. In one check of ours (2026-11-06, a 640 × 360 synthetic screenshot saved with the sharp/libvips encoder in Node.js, not WordPress's GD or Imagick), the file was 17,459 bytes at 82, 22,487 at 92 and 32,859 at 100, while the share of pixels changed by more than 15 of 255 levels only fell from 2.61% at 92 to 2.31% at 100. Move the slider and watch the byte count under the preview. For screenshots and UI graphics, try 85 to 92 and compare.
Does changing this fix images I already uploaded?
Not on its own. The filter applies to files WordPress writes after it is active. Regenerating the sizes, for example with wp media regenerate in WP-CLI, rebuilds them from your original, so they should get the new quality. We read that from the WordPress 7.1.4 source and have not tested it.