Attach orphan attachments when inserting into a post, fixes #8490

git-svn-id: https://develop.svn.wordpress.org/trunk@10062 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2008-12-05 06:21:42 +00:00
parent 723a52a32e
commit ca3acca0fb

View File

@ -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<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) {
$parent = (int) $_REQUEST['post_id'];
$parent_name = "attachments[$attachment_id][post_parent]";
$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n";
}
return $item;
}