When WordPress processes uploaded images, scaling them to different sizes, stripping metadata, or applying edits through the built-in image editor, it saves JPEGs at a quality setting of 82 by default. This is a reasonable middle ground, but it’s not always the right choice for every site. High-traffic sites focused on page speed may want to drop to 75 or 70 for a significant file size reduction with minimal visible quality loss. Photography portfolios and sites where image fidelity matters more than load time may want to push to 90 or higher.
This snippet gives you control over that number with a single filter, applied consistently to all JPEG processing WordPress performs.
The Code
Add this to your functions.php or a site-specific plugin. Two filters are used: jpeg_quality covers image processing during upload and thumbnail generation, while wp_editor_set_quality covers images edited and saved through WordPress’s built-in image editor (crop, rotate, scale).
Choosing the Right Quality Value
JPEG compression is not linear in its perceptible effect. The visual difference between quality 95 and 100 is almost imperceptible, while the file size difference is substantial. The practical range for web images is 70 to 90:
At 70–75, images are noticeably smaller, often 40–60% the size of the same image at 85, with compression artefacts that are visible on close inspection but generally acceptable for editorial and blog photography. This is the range used by Google’s WebP compression guidance and image CDN defaults.
At 80–85, the default zone, compression artefacts are minimal and most users won’t notice any quality difference compared to higher settings. This is the sweet spot for general-purpose sites.
At 90–95, quality is excellent and artefacts are essentially invisible, but files are significantly larger. Appropriate for photography portfolios, product imagery for e-commerce, and any use case where zooming or full-screen display is expected.
This Only Affects New Uploads
Changing this setting affects images processed after the snippet is added, new uploads and any images re-generated via a tool like Regenerate Thumbnails. Existing uploaded images on your server are not reprocessed automatically. If you want the new quality setting applied to all existing images, run a thumbnail regeneration after activating the snippet using the Regenerate Thumbnails plugin or the WP-CLI command wp media regenerate --yes.
WebP and Modern Formats
WordPress 5.8 and later can generate WebP versions of uploaded images when the server’s image library supports it. The jpeg_quality filter does not affect WebP output quality, WebP has its own separate quality setting managed through the webp_quality filter introduced in WordPress 6.1. If your site serves WebP images, add a matching filter for that format as well.
add_filter( 'jpeg_quality', function( $quality ) {
return 85; // Range: 0 (worst) to 100 (best). 75-85 is the practical sweet spot.
} );
// Also apply to images edited via the built-in image editor
add_filter( 'wp_editor_set_quality', function( $quality ) {
return 85;
} );
