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

git-svn-id: https://develop.svn.wordpress.org/trunk@4628 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2006-12-07 22:42:22 +00:00
parent bc386e1784
commit e8184e1027
4 changed files with 122 additions and 124 deletions

View File

@@ -220,34 +220,7 @@ function wp_upload_tab_upload_action() {
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
// Generate the attachment's postmeta.
$imagesize = getimagesize($file);
$imagedata['width'] = $imagesize['0'];
$imagedata['height'] = $imagesize['1'];
list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
$imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
$imagedata['file'] = $file;
wp_update_attachment_metadata( $id, $imagedata );
if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
$thumb = wp_create_thumbnail($file, 128);
elseif ( $imagedata['height'] > 96 )
$thumb = wp_create_thumbnail($file, 96);
if ( @file_exists($thumb) ) {
$newdata = $imagedata;
$newdata['thumb'] = basename($thumb);
wp_update_attachment_metadata( $id, $newdata );
} else {
$error = $thumb;
}
}
} else {
wp_update_attachment_metadata( $id, array() );
}
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
die;