image_max_bit_depth
Filter HookDescription
Filters the maximum bit depth of resized images. This filter only applies when resizing using the Imagick editor since GD does not support getting or setting bit depth. Use this to adjust the maximum bit depth of resized images.Hook Information
File Location |
wp-includes/class-wp-image-editor-imagick.php
View on GitHub
|
Hook Type | Filter |
Line Number | 552 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$max_depth
|
The maximum bit depth. Default is the input depth. |
int
|
$image_depth
|
The bit depth of the original image. |
Usage Examples
Basic Usage
<?php
// Hook into image_max_bit_depth
add_filter('image_max_bit_depth', 'my_custom_filter', 10, 2);
function my_custom_filter($max_depth, $image_depth) {
// Your custom filtering logic here
return $max_depth;
}
Source Code Context
wp-includes/class-wp-image-editor-imagick.php:552
- How this hook is used in WordPress core
<?php
547 * @since 6.8.0
548 *
549 * @param int $max_depth The maximum bit depth. Default is the input depth.
550 * @param int $image_depth The bit depth of the original image.
551 */
552 $max_depth = apply_filters( 'image_max_bit_depth', $this->image->getImageDepth(), $this->image->getImageDepth() );
553 $this->image->setImageDepth( $max_depth );
554 }
555 } catch ( Exception $e ) {
556 return new WP_Error( 'image_resize_error', $e->getMessage() );
557 }
PHP Documentation
<?php
/**
* Filters the maximum bit depth of resized images.
*
* This filter only applies when resizing using the Imagick editor since GD
* does not support getting or setting bit depth.
*
* Use this to adjust the maximum bit depth of resized images.
*
* @since 6.8.0
*
* @param int $max_depth The maximum bit depth. Default is the input depth.
* @param int $image_depth The bit depth of the original image.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-image-editor-imagick.php
Related Hooks
Related hooks will be displayed here in future updates.