wp_constrain_dimensions
Filter HookDescription
Filters dimensions to constrain down-sampled images to. }Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 518 |
Hook Parameters
Type | Name | Description |
---|---|---|
int[]
|
$dimensions
|
{ An array of width and height values. |
int
|
$current_width
|
The current width of the image. |
int
|
$current_height
|
The current height of the image. |
int
|
$max_width
|
The maximum width permitted. |
int
|
$max_height
|
The maximum height permitted. |
Usage Examples
Basic Usage
<?php
// Hook into wp_constrain_dimensions
add_filter('wp_constrain_dimensions', 'my_custom_filter', 10, 5);
function my_custom_filter($dimensions, $current_width, $current_height, $max_width, $max_height) {
// Your custom filtering logic here
return $dimensions;
}
Source Code Context
wp-includes/media.php:518
- How this hook is used in WordPress core
<?php
513 * @param int $current_width The current width of the image.
514 * @param int $current_height The current height of the image.
515 * @param int $max_width The maximum width permitted.
516 * @param int $max_height The maximum height permitted.
517 */
518 return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height );
519 }
520
521 /**
522 * Retrieves calculated resize dimensions for use in WP_Image_Editor.
523 *
PHP Documentation
<?php
/**
* Filters dimensions to constrain down-sampled images to.
*
* @since 4.1.0
*
* @param int[] $dimensions {
* An array of width and height values.
*
* @type int $0 The width in pixels.
* @type int $1 The height in pixels.
* }
* @param int $current_width The current width of the image.
* @param int $current_height The current height of the image.
* @param int $max_width The maximum width permitted.
* @param int $max_height The maximum height permitted.
*/
Quick Info
- Hook Type: Filter
- Parameters: 5
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.