From bdb5cde322d0e6b4166c971f13411a5075aaa058 Mon Sep 17 00:00:00 2001 From: azaozz Date: Fri, 5 Dec 2008 06:21:42 +0000 Subject: [PATCH] Attach orphan attachments when inserting into a post, fixes #8490 git-svn-id: http://svn.automattic.com/wordpress/trunk@10062 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 87ac47f0b..0062d4d8d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -372,6 +372,8 @@ function media_upload_form_handler() { $post['post_excerpt'] = $attachment['post_excerpt']; if ( isset($attachment['menu_order']) ) $post['menu_order'] = $attachment['menu_order']; + if ( isset($attachment['post_parent']) ) + $post['post_parent'] = $attachment['post_parent']; $post = apply_filters('attachment_fields_to_save', $post, $attachment); @@ -1185,6 +1187,13 @@ function get_media_item( $attachment_id, $args = null ) { foreach ( $hidden_fields as $name => $value ) $item .= "\t\n"; + if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) { + $parent = (int) $_REQUEST['post_id']; + $parent_name = "attachments[$attachment_id][post_parent]"; + + $item .= "\t\n"; + } + return $item; }