wp_expand_dimensions() WordPress Function

The wp_expand_dimensions() function is used to add new dimensions to an image. This is useful for resizing images that are too small or for creating thumbnails.

wp_expand_dimensions( int $example_width, int $example_height, int $max_width, int $max_height ) #

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


Description

Top ↑

See also


Top ↑

Parameters

$example_width

(int)(Required)The width of an example embed.

$example_height

(int)(Required)The height of an example embed.

$max_width

(int)(Required)The maximum allowed width.

$max_height

(int)(Required)The maximum allowed height.


Top ↑

Return

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

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


Top ↑

Source

File: wp-includes/media.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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.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