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.
Использование
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(строка)
- Image mime type.
- $size(массив)
Dimensions of the image.
-
width(int)
The image width. - height(int)
The image height.
-
Список изменений
С версии 3.5.0 | Введена. |
С версии 6.8.0 | Added the size parameter. |
Где вызывается хук
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 );