wp_editor_set_quality
Filters the default image compression quality setting.
Applies only during initial editor instantiation, or when set_quality() is run manually without the $quality argument.
The WP_Image_Editor::set_quality() method has priority over the filter.
Usage
add_filter( 'wp_editor_set_quality', 'wp_kama_editor_set_quality_filter', 10, 3 );
/**
* Function for `wp_editor_set_quality` filter-hook.
*
* @param int $quality Quality level between 1 (low) and 100 (high).
* @param string $mime_type Image mime type.
* @param array $size Dimensions of the image.
*
* @return int
*/
function wp_kama_editor_set_quality_filter( $quality, $mime_type, $size ){
// filter...
return $quality;
}
- $quality(int)
- Quality level between 1 (low) and 100 (high).
- $mime_type(string)
- Image mime type.
- $size(array)
Dimensions of the image.
-
width(int)
The image width. - height(int)
The image height.
-
Changelog
| Since 3.5.0 | Introduced. |
| Since 6.8.0 | Added the size parameter. |
Where the hook is called
wp_editor_set_quality
wp-includes/class-wp-image-editor.php 277
$quality = apply_filters( 'wp_editor_set_quality', $default_quality, $mime_type, $dims ? $dims : $this->size );