Collect intermediate images before deleting an attachment and its meta. Fixes thumbnail deletion. Props SergeyBiryukov. fixes #20658
git-svn-id: http://core.svn.wordpress.org/trunk@20770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a0f07732d4
commit
d58d5993b0
|
@ -3823,6 +3823,12 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
|||
$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
|
||||
$file = get_attached_file( $post_id );
|
||||
|
||||
$intermediate_sizes = array();
|
||||
foreach ( get_intermediate_image_sizes() as $size ) {
|
||||
if ( $intermediate = image_get_intermediate_size( $post_id, $size ) )
|
||||
$intermediate_sizes[] = $intermediate;
|
||||
}
|
||||
|
||||
if ( is_multisite() )
|
||||
delete_transient( 'dirsize_cache' );
|
||||
|
||||
|
@ -3857,12 +3863,10 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
|||
}
|
||||
|
||||
// remove intermediate and backup images if there are any
|
||||
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']);
|
||||
foreach ( $intermediate_sizes as $intermediate ) {
|
||||
$intermediate_file = apply_filters( 'wp_delete_file', $intermediate['path'] );
|
||||
@ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array($backup_sizes) ) {
|
||||
foreach ( $backup_sizes as $size ) {
|
||||
|
|
Loading…
Reference in New Issue