Set JPEG Compression Quality
Changes the quality used when WordPress generates resized JPEG images. Lower values give smaller files; the default is 82.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.