Collect intermediate images before deleting an attachment and its meta. Fixes thumbnail deletion. Props SergeyBiryukov. fixes #20658
git-svn-id: https://develop.svn.wordpress.org/trunk@20770 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9ffc69487f
commit
9b8b0bffac
@ -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,11 +3863,9 @@ 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']);
|
||||
@ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
|
||||
}
|
||||
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) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user