diff --git a/wp-includes/media.php b/wp-includes/media.php index b6fd593fa7..742b1bce62 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -84,7 +84,9 @@ function image_downsize($id, $size = 'medium') { list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); } - return array( $img_url, $width, $height ); + if ( $img_url) + return array( $img_url, $width, $height ); + return false; } @@ -284,7 +286,14 @@ function image_get_intermediate_size($post_id, $size='thumbnail') { if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) return false; - return $imagedata['sizes'][$size]; + $data = $imagedata['sizes'][$size]; + // include the full filesystem path of the intermediate file + if ( empty($data['path']) && !empty($data['file']) ) { + $file_url = wp_get_attachment_url($post_id); + $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); + $data['url'] = path_join( dirname($file_url), $data['file'] ); + } + return $data; } // get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images @@ -321,7 +330,6 @@ function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = fals return $html; } - add_shortcode('gallery', 'gallery_shortcode'); function gallery_shortcode($attr) { diff --git a/wp-includes/post.php b/wp-includes/post.php index e8287e0bdd..16eab3b7ee 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2180,6 +2180,15 @@ function wp_delete_attachment($postid) { } } + // remove intermediate images if there are any + $sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium')); + foreach ( $sizes as $size ) { + if ( $intermediate = image_get_intermediate_size($postid, $size) ) { + $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']); + @ unlink($intermediate_file); + } + } + $file = apply_filters('wp_delete_file', $file); if ( ! empty($file) )