Introduce a single function for getting all the intermediate image sizes to be used both when adding attachements and deleting. Fixes #10263 props scribu.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12659 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4d0c9da793
commit
cc30f8ad98
|
@ -102,13 +102,8 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
|
||||
// make thumbnails and other intermediate sizes
|
||||
global $_wp_additional_image_sizes;
|
||||
$temp_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
|
||||
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
|
||||
$temp_sizes = array_merge( $temp_sizes, array_keys( $_wp_additional_image_sizes ) );
|
||||
|
||||
$temp_sizes = apply_filters( 'intermediate_image_sizes', $temp_sizes );
|
||||
|
||||
foreach ( $temp_sizes as $s ) {
|
||||
foreach ( get_intermediate_image_sizes() as $s ) {
|
||||
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
|
||||
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
|
||||
$sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
|
||||
|
|
|
@ -506,6 +506,20 @@ function image_get_intermediate_size($post_id, $size='thumbnail') {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available image sizes
|
||||
* @since 3.0
|
||||
* @return array Returns a filtered array of image size strings
|
||||
*/
|
||||
function get_intermediate_image_sizes() {
|
||||
global $_wp_additional_image_sizes;
|
||||
$image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
|
||||
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
|
||||
$image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
|
||||
|
||||
return apply_filters( 'intermediate_image_sizes', $image_sizes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an image to represent an attachment.
|
||||
*
|
||||
|
|
|
@ -2946,8 +2946,7 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
|||
}
|
||||
|
||||
// remove intermediate and backup images if there are any
|
||||
$sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium', 'large'));
|
||||
foreach ( $sizes as $size ) {
|
||||
foreach ( get_intermediate_image_sizes() as $size ) {
|
||||
if ( $intermediate = image_get_intermediate_size($post_id, $size) ) {
|
||||
$intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
|
||||
@ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
|
||||
|
|
Loading…
Reference in New Issue