add_filter( 'big_image_size_threshold', function( $threshold ) {
return 1200; // max width in pixels
}, 10, 1 );
Resize and compress the images
// Set max image width to 1200px
add_filter( 'big_image_size_threshold', function( $threshold ) {
return 1200;
});
// Set JPEG compression quality to 80%
add_filter( 'jpeg_quality', function( $quality ) {
return 80;
});
add_filter( 'wp_editor_set_quality', function( $quality ) {
return 80;
});
Convert PNG → WebP (smaller size + transparency support)
add_filter( 'wp_editor_set_quality', function( $quality, $mime_type ) {
if ( $mime_type === 'image/webp' ) {
return 80;
}
return $quality;
}, 10, 2 );