Last active
September 13, 2019 19:20
-
-
Save stephanieleary/38d7a4d2fa127e2da00468da8c499413 to your computer and use it in GitHub Desktop.
Filter PNG image quality in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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