Warning: This function has been deprecated. Use wp_constrain_dimensions() instead.

wp_shrink_dimensions() WordPress Function

wp_shrink_dimensions() is a function that allows you to resize an image to fit within a given width and height. This is useful for creating thumbnails or for resizing images that are too large for your website's layout.

wp_shrink_dimensions( int $width, int $height, int $wmax = 128, int $hmax = 96 ) #

Calculates the new dimensions for a downsampled image.


Description

Top ↑

See also


Top ↑

Parameters

$width

(int)(Required)Current width of the image

$height

(int)(Required)Current height of the image

$wmax

(int)(Optional)Maximum wanted width

Default value: 128

$hmax

(int)(Optional)Maximum wanted height

Default value: 96


Top ↑

Return

(array) Shrunk dimensions (width, height).


Top ↑

Source

File: wp-admin/includes/deprecated.php

function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_constrain_dimensions()' );
	return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Use wp_constrain_dimensions()
2.0.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.