Make WordPress Core

Changeset 29816


Ignore:
Timestamp:
10/02/2014 03:31:57 PM (10 years ago)
Author:
wonderboymusic
Message:

In wp_delete_attachment(): account for orphan sizes by looping over the sizes stored in metadata, instead of relying on the current sizes stored in $_wp_additional_image_sizes.

Props JoshuaAbenazer, desrosj, markoheijnen.
Fixes #24518.

File:
1 edited

Legend:

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

    r29752 r29816  
    47724772    $file = get_attached_file( $post_id );
    47734773
    4774     $intermediate_sizes = array();
    4775     foreach ( get_intermediate_image_sizes() as $size ) {
    4776         if ( $intermediate = image_get_intermediate_size( $post_id, $size ) )
    4777             $intermediate_sizes[] = $intermediate;
    4778     }
    4779 
    47804774    if ( is_multisite() )
    47814775        delete_transient( 'dirsize_cache' );
     
    48264820
    48274821    // Remove intermediate and backup images if there are any.
    4828     foreach ( $intermediate_sizes as $intermediate ) {
    4829         /** This filter is documented in wp-admin/custom-header.php */
    4830         $intermediate_file = apply_filters( 'wp_delete_file', $intermediate['path'] );
    4831         @ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
     4822    if ( isset( $meta['sizes'] ) && is_array( $meta['sizes'] ) ) {
     4823        foreach ( $meta['sizes'] as $size => $sizeinfo ) {
     4824            $intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
     4825            /** This filter is documented in wp-admin/custom-header.php */
     4826            $intermediate_file = apply_filters( 'wp_delete_file', $intermediate_file );
     4827            @ unlink( path_join( $uploadpath['basedir'], $intermediate_file ) );
     4828        }
    48324829    }
    48334830
Note: See TracChangeset for help on using the changeset viewer.