image_resize_dimensions WordPress Filter Hook

The image_resize_dimensions hook is used to alter the dimensions of an image being resized. This can be useful for making sure that an image fits within a specific space, or for ensuring that an image is a certain size when it is being displayed.

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

Filters whether to preempt calculating the image resize dimensions.


Description

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


Top ↑

Parameters

$null

(null|mixed)Whether to preempt output of the resize dimensions.

$orig_w

(int)Original width in pixels.

$orig_h

(int)Original height in pixels.

$dest_w

(int)New width in pixels.

$dest_h

(int)New height in pixels.

$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.


Top ↑

More Information

  • Since version 3.4, the image_resize_dimensions filter is used to filter the thumbnail and alternative sizes dimensions of image assets during resizing operations. This enables the override of WordPress default behavior on image resizing, including the thumbnail cropping.
  • Note that the filter function must return an array matching the parameters to imagecopyresampled(), or false if the resizing is impossible, or should not occur, or null to fallback to WordPress default behavior.

Top ↑

Source

File: wp-includes/media.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More