Make WordPress Core

Ticket #18060: 18060-0304.diff

File 18060-0304.diff, 1.3 KB (added by rfc1437, 13 years ago)

fixed patch for 3.4

  • wp-includes/class-wp-atom-server.php

    old new  
    542542
    543543                $url = $file['url'];
    544544                $file = $file['file'];
     545                $title = $content = $slug;
    545546
    546547                do_action('wp_create_file_in_uploads', $file); // replicate
    547548
     549                if ( $image_meta = @wp_read_image_metadata($file) ) {
     550                        if ( trim ( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
     551                                $title = $image_meta['title'];
     552                        if ( trim( $image_meta['caption'] ) )
     553                                $content = $image_meta['caption'];
     554                }
     555
    548556                // Construct the attachment array
    549557                $attachment = array(
    550                         'post_title' => $slug,
    551                         'post_content' => $slug,
     558                        'post_title' => $title,
     559                        'post_content' => $content,
    552560                        'post_status' => 'attachment',
    553561                        'post_parent' => 0,
    554562                        'post_mime_type' => $type,
     
    558566                // Save the data
    559567                $postID = wp_insert_attachment($attachment, $file);
    560568
    561                 if (!$postID)
     569                if ( is_wp_error( $postID ) ) {
    562570                        $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
     571                } else {
     572                        wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $file ) ) ;
     573                }
    563574
    564575                $output = $this->get_entry($postID, 'attachment');
    565576