wp_constrain_dimensions

SummerySummery

Calculates the new dimensions for a down-sampled image.

Syntax

wp_constrain_dimensions( int $current_width, int $current_height, int $max_width, int $max_height )

DescriptionDescription

If either width or height are empty, no constraint is applied on that dimension.

ParametersParameters

$current_width

(int) (Required) Current width of the image.

$current_height

(int) (Required) Current height of the image.

$max_width

(int) (Optional) Max width in pixels to constrain to. Default 0.

$max_height

(int) (Optional) Max height in pixels to constrain to. Default 0.

ReturnReturn

(int[]) An array of width and height values.

  • (int) The width in pixels.
  • '1'
    (int) The height in pixels.

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
2.5.0 Introduced.
Scroll to Top