From 72e74add8df70439b246362a3740b866a62a4ec9 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 22 Sep 2007 16:30:40 +0000 Subject: [PATCH] Don't reset parent when updating attachment. Props filosofo and michelwp. fixes #5010 git-svn-id: http://svn.automattic.com/wordpress/trunk@6155 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/upload.js | 1 + wp-includes/post.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-admin/js/upload.js b/wp-admin/js/upload.js index 6eca5705bb..d38cdcb036 100644 --- a/wp-admin/js/upload.js +++ b/wp-admin/js/upload.js @@ -201,6 +201,7 @@ addLoadEvent( function() { h += ""; h += ""; h += ""; + h += ""; h += ""; h += ""; h += ""; diff --git a/wp-includes/post.php b/wp-includes/post.php index 080eb6bf22..89e2175ba2 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1272,7 +1272,7 @@ function is_local_attachment($url) { return false; } -function wp_insert_attachment($object, $file = false, $post_parent = 0) { +function wp_insert_attachment($object, $file = false, $parent = 0) { global $wpdb, $user_ID; $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, @@ -1280,6 +1280,9 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) { 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => ''); $object = wp_parse_args($object, $defaults); + if ( !empty($parent) ) + $object['post_parent'] = $parent; + $object = sanitize_post($object, 'db'); // export array as variables