wp_editor_set_quality
Filter HookDescription
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. }Hook Information
File Location |
wp-includes/class-wp-image-editor.php
View on GitHub
|
Hook Type | Filter |
Line Number | 277 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$quality
|
Quality level between 1 (low) and 100 (high). |
string
|
$mime_type
|
Image mime type. |
array
|
$size
|
{ Dimensions of the image. |
Usage Examples
Basic Usage
<?php
// Hook into wp_editor_set_quality
add_filter('wp_editor_set_quality', 'my_custom_filter', 10, 3);
function my_custom_filter($quality, $mime_type, $size) {
// Your custom filtering logic here
return $quality;
}
Source Code Context
wp-includes/class-wp-image-editor.php:277
- How this hook is used in WordPress core
<?php
272 *
273 * @type int $width The image width.
274 * @type int $height The image height.
275 * }
276 */
277 $quality = apply_filters( 'wp_editor_set_quality', $default_quality, $mime_type, $dims ? $dims : $this->size );
278
279 if ( 'image/jpeg' === $mime_type ) {
280 /**
281 * Filters the JPEG compression quality for backward-compatibility.
282 *
PHP Documentation
<?php
/**
* 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.
*
* @since 3.5.0
* @since 6.8.0 Added the size parameter.
*
* @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.
*
* @type int $width The image width.
* @type int $height The image height.
* }
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/class-wp-image-editor.php
Related Hooks
Related hooks will be displayed here in future updates.