wp_constrain_dimensions filter-hookWP 4.1.0

Filters dimensions to constrain down-sampled images to.

Usage

add_filter( 'wp_constrain_dimensions', 'wp_kama_constrain_dimensions_filter', 10, 5 );

/**
 * Function for `wp_constrain_dimensions` filter-hook.
 * 
 * @param int[] $dimensions     An array of width and height values.
 * @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.
 *
 * @return int[]
 */
function wp_kama_constrain_dimensions_filter( $dimensions, $current_width, $current_height, $max_width, $max_height ){

	// filter...
	return $dimensions;
}
$dimensions(int[])

An array of width and height values.

  • 0(int)
    The width in pixels.

  • 1(int)
    The height in pixels.
$current_width(int)
The current width of the image.
$current_height(int)
The current height of the image.
$max_width(int)
The maximum width permitted.
$max_height(int)
The maximum height permitted.

Changelog

Since 4.1.0 Introduced.

Where the hook is called

wp_constrain_dimensions()
wp_constrain_dimensions
wp-includes/media.php 513
return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height );

Where the hook is used in WordPress

Usage not found.