Ticket #18060: 18060.diff
File 18060.diff, 1.3 KB (added by , 14 years ago) |
---|
-
wp-app.php
620 620 621 621 $url = $file['url']; 622 622 $file = $file['file']; 623 $title = $content = $slug; 623 624 624 625 do_action('wp_create_file_in_uploads', $file); // replicate 625 626 627 // use image exif/iptc data for title and caption defaults if possible 628 if ( $image_meta = @wp_read_image_metadata($file) ) { 629 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) 630 $title = $image_meta['title']; 631 if ( trim( $image_meta['caption'] ) ) 632 $content = $image_meta['caption']; 633 } 634 626 635 // Construct the attachment array 627 636 $attachment = array( 628 'post_title' => $ slug,629 'post_content' => $ slug,637 'post_title' => $title, 638 'post_content' => $content, 630 639 'post_status' => 'attachment', 631 640 'post_parent' => 0, 632 641 'post_mime_type' => $type, … … 636 645 // Save the data 637 646 $postID = wp_insert_attachment($attachment, $file); 638 647 639 if ( !$postID)648 if ( is_wp_error( $postID ) ) { 640 649 $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); 650 } else { 651 wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $file ) ); 652 } 641 653 642 654 $output = $this->get_entry($postID, 'attachment'); 643 655