WordPress.org

Make WordPress Core

Changeset 20770


Ignore:
Timestamp:
05/11/12 18:47:32 (2 years ago)
Author:
ryan
Message:

Collect intermediate images before deleting an attachment and its meta. Fixes thumbnail deletion. Props SergeyBiryukov. fixes #20658

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r20739 r20770  
    38243824    $file = get_attached_file( $post_id ); 
    38253825 
     3826    $intermediate_sizes = array(); 
     3827    foreach ( get_intermediate_image_sizes() as $size ) { 
     3828        if ( $intermediate = image_get_intermediate_size( $post_id, $size ) ) 
     3829            $intermediate_sizes[] = $intermediate; 
     3830    } 
     3831 
    38263832    if ( is_multisite() ) 
    38273833        delete_transient( 'dirsize_cache' ); 
     
    38583864 
    38593865    // remove intermediate and backup images if there are any 
    3860     foreach ( get_intermediate_image_sizes() as $size ) { 
    3861         if ( $intermediate = image_get_intermediate_size($post_id, $size) ) { 
    3862             $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']); 
    3863             @ unlink( path_join($uploadpath['basedir'], $intermediate_file) ); 
    3864         } 
     3866    foreach ( $intermediate_sizes as $intermediate ) { 
     3867        $intermediate_file = apply_filters( 'wp_delete_file', $intermediate['path'] ); 
     3868        @ unlink( path_join($uploadpath['basedir'], $intermediate_file) ); 
    38653869    } 
    38663870 
Note: See TracChangeset for help on using the changeset viewer.