Add remove_image_size() and tests for it and has_image_size(), added in [27128].
props mordauk, markoheijnen. fixes #26768. see #26951. Built from https://develop.svn.wordpress.org/trunk@27129 git-svn-id: http://core.svn.wordpress.org/trunk@26996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2610e6d4ff
commit
53867f3081
|
@ -181,27 +181,55 @@ function image_downsize($id, $size = 'medium') {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a new image size
|
* Register a new image size.
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
|
*
|
||||||
|
* @param string $name The image size name.
|
||||||
|
* @param int $width The image's width.
|
||||||
|
* @param int $height The image's width.
|
||||||
|
* @param bool $width Whether to crop the image to fit the dimensions. Default false.
|
||||||
*/
|
*/
|
||||||
function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
|
function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
|
||||||
global $_wp_additional_image_sizes;
|
global $_wp_additional_image_sizes;
|
||||||
$_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop );
|
$_wp_additional_image_sizes[ $name ] = array(
|
||||||
|
'width' => absint( $width ),
|
||||||
|
'height' => absint( $height ),
|
||||||
|
'crop' => (bool) $crop,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an image size exists
|
* Check if an image size exists.
|
||||||
*
|
*
|
||||||
* @since 3.9.0
|
* @since 3.9.0
|
||||||
*
|
*
|
||||||
* @param string $name The image size name.
|
* @param string $name The image size to check.
|
||||||
* @return bool True if it exists, false if not.
|
* @return bool True if it exists, false if not.
|
||||||
*/
|
*/
|
||||||
function has_image_size( $name = '' ) {
|
function has_image_size( $name = '' ) {
|
||||||
global $_wp_additional_image_sizes;
|
global $_wp_additional_image_sizes;
|
||||||
|
|
||||||
return isset( $_wp_additional_image_sizes[$name] );
|
return isset( $_wp_additional_image_sizes[ $name ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a new image size.
|
||||||
|
*
|
||||||
|
* @since 3.9.0
|
||||||
|
*
|
||||||
|
* @param string $name The image size to remove.
|
||||||
|
* @return bool True on success, false on failure.
|
||||||
|
*/
|
||||||
|
function remove_image_size( $name ) {
|
||||||
|
global $_wp_additional_image_sizes;
|
||||||
|
|
||||||
|
if ( isset( $_wp_additional_image_sizes[ $name ] ) ) {
|
||||||
|
unset( $_wp_additional_image_sizes[ $name ] );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue