diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index cd88e4dc81..943b2d85b4 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -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 diff --git a/wp-includes/media.php b/wp-includes/media.php index 318a6350f0..a466d719cc 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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. * diff --git a/wp-includes/post.php b/wp-includes/post.php index a2891a315b..bb0ff0bab0 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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) );