WordPress.org

Make WordPress Core

Changeset 9846


Ignore:
Timestamp:
11/22/2008 11:01:28 PM (12 years ago)
Author:
westi
Message:

Ensure that thumbnails are removed when the media file is deleted. Fixes #8309 props jacobsantos.

File:
1 edited

Legend:

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

    r9803 r9846  
    2222 * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID.
    2323 *
    24  * @param int $attachment_id Attachment ID
    25  * @param bool $unfiltered Whether to apply filters or not
     24 * @param int $attachment_id Attachment ID.
     25 * @param bool $unfiltered Whether to apply filters or not.
    2626 * @return string The file path to the attached file.
    2727 */
     
    24192419    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
    24202420
     2421    $uploadPath = wp_upload_dir();
     2422
    24212423    if ( ! empty($meta['thumb']) ) {
    24222424        // Don't delete the thumb if another attachment uses it
     
    24242426            $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
    24252427            $thumbfile = apply_filters('wp_delete_file', $thumbfile);
    2426             @ unlink($thumbfile);
     2428            @ unlink( path_join($uploadPath['basedir'], $thumbfile) );
    24272429        }
    24282430    }
     
    24332435        if ( $intermediate = image_get_intermediate_size($postid, $size) ) {
    24342436            $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
    2435             @ unlink($intermediate_file);
     2437            @ unlink( path_join($uploadPath['basedir'], $intermediate_file) );
    24362438        }
    24372439    }
Note: See TracChangeset for help on using the changeset viewer.