Title: wp_expand_dimensions
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_expand_dimensions( int $example_width, int $example_height, int $max_width, int $max_height ): int[]

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#wp--skip-link--target)

Based on a supplied width/height example, returns the biggest possible dimensions
based on the max width/height.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#see-also)󠁿

 * [wp_constrain_dimensions()](https://developer.wordpress.org/reference/functions/wp_constrain_dimensions/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#parameters)󠁿

 `$example_width`intrequired

The width of an example embed.

`$example_height`intrequired

The height of an example embed.

`$max_width`intrequired

The maximum allowed width.

`$max_height`intrequired

The maximum allowed height.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#return)󠁿

 int[] An array of maximum width and height values.

 * `0` int
 * The maximum width in pixels.
 * `1` int
 * The maximum height in pixels.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#source)󠁿

    ```php
    function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) {
    	$example_width  = (int) $example_width;
    	$example_height = (int) $example_height;
    	$max_width      = (int) $max_width;
    	$max_height     = (int) $max_height;

    	return wp_constrain_dimensions( $example_width * 1000000, $example_height * 1000000, $max_width, $max_height );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/media.php#L4171)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/media.php#L4171-L4178)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_constrain_dimensions()](https://developer.wordpress.org/reference/functions/wp_constrain_dimensions/)`wp-includes/media.php` |

Calculates the new dimensions for a down-sampled image.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_expand_dimensions/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_expand_dimensions%2F)
before being able to contribute a note or feedback.