Deprecate wp_shrink_dimension(), add wp-admin/includes/deprecated.php. Props filosofo. fixes #11967

git-svn-id: http://svn.automattic.com/wordpress/trunk@12823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-25 18:50:01 +00:00
parent 504c7a7e0b
commit a7c1b164f6
5 changed files with 30 additions and 23 deletions

View File

@ -51,6 +51,9 @@ require_once(ABSPATH . 'wp-admin/includes/update.php');
/** WordPress Registration API */
require_once(ABSPATH . WPINC . '/registration.php');
/** WordPress Deprecated Administration API */
require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
/** WordPress Multi-Site support API */
if ( is_multisite() )
require_once(ABSPATH . 'wp-admin/includes/ms.php');

View File

@ -0,0 +1,21 @@
<?php
/**
* Calculates the new dimentions for a downsampled image.
*
* @since 2.0.0
* @deprecated 3.0.0
* @deprecated Use wp_constrain_dimensions()
*
* @param int $width Current width of the image
* @param int $height Current height of the image
* @param int $wmax Maximum wanted width
* @param int $hmax Maximum wanted height
* @return mixed Array(height,width) of shrunk dimensions.
*/
function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
}
?>

View File

@ -453,7 +453,7 @@ function wp_restore_image($post_id) {
$meta['file'] = _wp_relative_upload_path( $restored_file );
$meta['width'] = $data['width'];
$meta['height'] = $data['height'];
list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
}
@ -598,7 +598,7 @@ function wp_save_image($post_id) {
$meta['width'] = imagesx($img);
$meta['height'] = imagesy($img);
list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
if ( $success && ('nothumb' == $target || 'all' == $target) ) {

View File

@ -94,7 +94,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$imagesize = getimagesize( $file );
$metadata['width'] = $imagesize[0];
$metadata['height'] = $imagesize[1];
list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
// Make the file path relative to the upload dir
@ -169,30 +169,14 @@ function wp_load_image( $file ) {
* Calculated the new dimentions for a downsampled image.
*
* @since 2.0.0
* @see wp_shrink_dimensions()
* @see wp_constrain_dimensions()
*
* @param int $width Current width of the image
* @param int $height Current height of the image
* @return mixed Array(height,width) of shrunk dimensions.
*/
function get_udims( $width, $height) {
return wp_shrink_dimensions( $width, $height );
}
/**
* Calculates the new dimentions for a downsampled image.
*
* @since 2.0.0
* @see wp_constrain_dimensions()
*
* @param int $width Current width of the image
* @param int $height Current height of the image
* @param int $wmax Maximum wanted width
* @param int $hmax Maximum wanted height
* @return mixed Array(height,width) of shrunk dimensions.
*/
function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
return wp_constrain_dimensions( $width, $height, 128, 96 );
}
/**

View File

@ -233,8 +233,7 @@ function get_image_tag($id, $alt, $title, $align, $size='medium') {
/**
* Calculates the new dimentions for a downsampled image.
*
* Same as {@link wp_shrink_dimensions()}, except the max parameters are
* optional. If either width or height are empty, no constraint is applied on
* If either width or height are empty, no constraint is applied on
* that dimension.
*
* @since 2.5.0