wp_constrain_dimensions

Filters dimensions to constrain down-sampled images to.

Description

apply_filters( 'wp_constrain_dimensions', (array) $array, (int) $current_width, (int) $current_height, (int) $max_width, (int) $max_height ); 

Parameters (5)

0. $array (array) => array( $w, $h )
The image width and height.
1. $current_width (int)
The current width of the image.
2. $current_height (int)
The current height of the image.
3. $max_width (int)
The maximum width permitted.
4. $max_height (int)
The maximum height permitted.

Usage

To run the hook, copy the example below.
  1. $array = apply_filters( 'wp_constrain_dimensions', $array, $current_width, $current_height, $max_width, $max_height ); 
  2.  
  3. if ( !empty( $array ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_constrain_dimensions callback 
  2. function filter_wp_constrain_dimensions( $array, $current_width, $current_height, $max_width, $max_height ) { 
  3. // make filter magic happen here... 
  4. return $array
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_constrain_dimensions', 'filter_wp_constrain_dimensions', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_constrain_dimensions', 'filter_wp_constrain_dimensions', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

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