Ticket #15432: media_handle_sideload.patch
File media_handle_sideload.patch, 1.2 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/media.php
283 283 284 284 // Save the attachment metadata 285 285 $id = wp_insert_attachment($attachment, $file, $post_id); 286 if ( !is_wp_error($id) ) {286 if ( !is_wp_error($id) ) 287 287 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 288 return $url; 289 } 288 290 289 return $id; 291 290 } 292 291 … … 518 517 $file_array['tmp_name'] = $tmp; 519 518 520 519 // If error storing temporarily, unlink 521 if ( is_wp_error( $tmp) ) {520 if ( is_wp_error( $tmp ) ) { 522 521 @unlink($file_array['tmp_name']); 523 522 $file_array['tmp_name'] = ''; 524 523 } 525 524 526 525 // do the validation and storage stuff 527 $id = media_handle_sideload($file_array, $post_id, @$desc); 528 $src = $id; 526 $id = media_handle_sideload( $file_array, $post_id, @$desc ); 529 527 530 528 // If error storing permanently, unlink 531 529 if ( is_wp_error($id) ) { 532 530 @unlink($file_array['tmp_name']); 533 531 return $id; 534 532 } 533 534 $src = get_attachment_link( $id ); 535 535 } 536 536 537 537 // Finally check to make sure the file has been saved, then return the html