Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Filter PNG image quality in WordPress
// well-known filter to change JPG quality:
add_filter( 'jpeg_quality', function( $arg ){ return 100; } );
// lesser-known filter to change quality for any image type:
add_filter( 'wp_editor_set_quality', 'any_image_quality', 10, 2 );
add_filter( 'jpeg_quality', 'any_image_quality' );
function any_image_quality( $default_quality, $mime_type = NULL ) {
// you could do if ( 'image/png' == $mime_type ) here if you want to be specific
return 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment