image_resize_dimensions

Filters whether to preempt calculating the image resize dimensions.

Description

apply_filters( 'image_resize_dimensions', (null) $null, (int) $orig_w, (int) $orig_h, (int) $dest_w, (int) $dest_h, (bool|array) $crop ); 

Passing a non-null value to the filter will effectively short-circuit image_resize_dimensions(), returning that value instead.

Parameters (6)

0. $null (null) => null
Whether to preempt output of the resize dimensions.
1. $orig_w (int)
Original width in pixels.
2. $orig_h (int)
Original height in pixels.
3. $dest_w (int)
New width in pixels.
4. $dest_h (int)
New height in pixels.
5. $crop (bool|array)
Whether to crop image to specified width and height or resize. An array can specify positioning of the crop area. Default false.

Usage

To run the hook, copy the example below.
  1. $null = apply_filters( 'image_resize_dimensions', $null, $orig_w, $orig_h, $dest_w, $dest_h, $crop ); 
  2.  
  3. if ( !empty( $null ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the image_resize_dimensions callback 
  2. function filter_image_resize_dimensions( $null, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) { 
  3. // make filter magic happen here... 
  4. return $null
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'image_resize_dimensions', 'filter_image_resize_dimensions', 10, 6 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'image_resize_dimensions', 'filter_image_resize_dimensions', 10, 6 ); 

Defined (1)

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

/wp-includes/media.php  
  1. $output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop );