# Set JPEG Compression Quality

> Changes the quality used when WordPress generates resized JPEG images. Lower values give smaller files; the default is 82.

- Type: PHP
- Runs: Run everywhere
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: media, images, jpeg, compression
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/jpeg-compression-quality/

## Code

```php
add_filter( 'wp_editor_set_quality', function ( $quality, $mime_type ) {
    return 'image/jpeg' === $mime_type ? 75 : $quality;
}, 10, 2 );
```

## Notes

Applies to images uploaded after activation. Use a thumbnail regeneration tool for existing images.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Set JPEG Compression Quality" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
