jpeg_quality
Filter HookDescription
Filters the JPEG compression quality for backward-compatibility. 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. The filter is evaluated under two contexts: 'image_resize', and 'edit_image', (when a JPEG image is saved to file).Hook Information
File Location |
wp-includes/class-wp-image-editor.php
View on GitHub
|
Hook Type | Filter |
Line Number | 296 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$quality
|
Quality level between 0 (low) and 100 (high) of the JPEG. |
string
|
$context
|
Context of the filter. |
Usage Examples
Basic Usage
<?php
// Hook into jpeg_quality
add_filter('jpeg_quality', 'my_custom_filter', 10, 2);
function my_custom_filter($quality, $context) {
// Your custom filtering logic here
return $quality;
}
Source Code Context
wp-includes/class-wp-image-editor.php:296
- How this hook is used in WordPress core
<?php
291 * @since 2.5.0
292 *
293 * @param int $quality Quality level between 0 (low) and 100 (high) of the JPEG.
294 * @param string $context Context of the filter.
295 */
296 $quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
297 }
298
299 if ( $quality < 0 || $quality > 100 ) {
300 $quality = $default_quality;
301 }
PHP Documentation
<?php
/**
* Filters the JPEG compression quality for backward-compatibility.
*
* 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.
*
* The filter is evaluated under two contexts: 'image_resize', and 'edit_image',
* (when a JPEG image is saved to file).
*
* @since 2.5.0
*
* @param int $quality Quality level between 0 (low) and 100 (high) of the JPEG.
* @param string $context Context of the filter.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-image-editor.php
Related Hooks
Related hooks will be displayed here in future updates.