WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp constrain dimensions

Contents

Description

Calculates the new dimensions for a down sampled image.

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

Usage

<?php wp_constrain_dimensions$current_width$current_height$max_width$max_height ); ?>

Parameters

$current_width
(int) (required) Current width of the image.
Default: None
$current_height
(int) (required) Current height of the image.
Default: None
$max_width
(int) (optional) Optional. Maximum wanted width.
Default: 0
$max_height
(int) (optional) Optional. Maximum wanted height.
Default: 0

Return Values

(array) 
First item is the width, the second item is the height.

Change Log

Since: 2.5

Source File

wp_constrain_dimensions() is located in wp-includes/media.php