Ticket #8309: 8309.1.diff
File 8309.1.diff, 1.6 KB (added by , 16 years ago) |
---|
-
post.php
21 21 * @since 2.0.0 22 22 * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID. 23 23 * 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. 26 26 * @return string The file path to the attached file. 27 27 */ 28 28 function get_attached_file( $attachment_id, $unfiltered = false ) { … … 2418 2418 2419 2419 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid )); 2420 2420 2421 $uploadPath = wp_upload_dir(); 2422 2421 2423 if ( ! empty($meta['thumb']) ) { 2422 2424 // Don't delete the thumb if another attachment uses it 2423 2425 if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%'.$meta['thumb'].'%', $postid)) ) { 2424 2426 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 2425 2427 $thumbfile = apply_filters('wp_delete_file', $thumbfile); 2426 @ unlink( $thumbfile);2428 @ unlink( path_join($uploadPath['basedir'], $thumbfile) ); 2427 2429 } 2428 2430 } 2429 2431 … … 2432 2434 foreach ( $sizes as $size ) { 2433 2435 if ( $intermediate = image_get_intermediate_size($postid, $size) ) { 2434 2436 $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']); 2435 @ unlink( $intermediate_file);2437 @ unlink( path_join($uploadPath['basedir'], $intermediate_file) ); 2436 2438 } 2437 2439 } 2438 2440