wppaste
WordPress

apply_filters( 'wp_editor_set_quality', int $quality, string $mime_type, array $size )

Since
3.5.0, 6.8.0
Filters the default image compression quality setting.

Description

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.

Compatibility

WordPress
since 6.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$qualityint
Quality level between 1 (low) and 100 (high).
$mime_typestring
Image mime type.
$sizearray
{ Dimensions of the image.
@type int $width The image width.
@type int $height The image height.
}
  • $widthint

    The image width.
  • $heightint

    The image height.

Where this hook fires · 1

  • wp-includes/class-wp-image-editor.php:269WP_Image_Editor::set_quality()

Source code

			 *     Dimensions of the image.			 *			 *     @type int $width  The image width.			 *     @type int $height The image height.			 * }			 */			$quality = apply_filters( 'wp_editor_set_quality', $default_quality, $mime_type, $dims ? $dims : $this->size ); 			if ( 'image/jpeg' === $mime_type ) {				/**				 * Filters the JPEG compression quality for backward-compatibility.				 *				 * Applies only during initial editor instantiation, or when set_quality() is run

Changelog

Introduced in 3.5.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.8.8
Parameter $size added.verified against source
6.8.0
Added the $size parameter.from the docblock
3.5.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.