Make WordPress Core


Ignore:
Timestamp:
12/07/2006 10:42:22 PM (20 years ago)
Author:
ryan
Message:

Create attachment metadata for xmlrpc uploads. Props mdawaffe. fixes #3452

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload-functions.php

    r4612 r4628  
    221221                $id = wp_insert_attachment($attachment, $file, $post_id);
    222222
    223                 if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
    224                         // Generate the attachment's postmeta.
    225                         $imagesize = getimagesize($file);
    226                         $imagedata['width'] = $imagesize['0'];
    227                         $imagedata['height'] = $imagesize['1'];
    228                         list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
    229                         $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    230                         $imagedata['file'] = $file;
    231 
    232                         wp_update_attachment_metadata( $id, $imagedata );
    233 
    234                         if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    235                                 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    236                                         $thumb = wp_create_thumbnail($file, 128);
    237                                 elseif ( $imagedata['height'] > 96 )
    238                                         $thumb = wp_create_thumbnail($file, 96);
    239 
    240                                 if ( @file_exists($thumb) ) {
    241                                         $newdata = $imagedata;
    242                                         $newdata['thumb'] = basename($thumb);
    243                                         wp_update_attachment_metadata( $id, $newdata );
    244                                 } else {
    245                                         $error = $thumb;
    246                                 }
    247                         }
    248                 } else {
    249                         wp_update_attachment_metadata( $id, array() );
    250                 }
     223                wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
    251224
    252225                wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
Note: See TracChangeset for help on using the changeset viewer.