mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-12 13:44:21 +01:00
Media: When inserting an attachment, if the item is unattached (no post_parent), attach it to the post. fixes #22085.
git-svn-id: http://core.svn.wordpress.org/trunk@22843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2105efa5bf
commit
ab5c08a120
@ -1931,6 +1931,11 @@ function wp_ajax_send_attachment_to_editor() {
|
|||||||
if ( 'attachment' != $post->post_type )
|
if ( 'attachment' != $post->post_type )
|
||||||
wp_send_json_error();
|
wp_send_json_error();
|
||||||
|
|
||||||
|
// If this attachment is unattached, attach it. Primarily a back compat thing.
|
||||||
|
if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
|
||||||
|
wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) );
|
||||||
|
}
|
||||||
|
|
||||||
$html = isset( $attachment['title'] ) ? $attachment['title'] : '';
|
$html = isset( $attachment['title'] ) ? $attachment['title'] : '';
|
||||||
if ( ! empty( $attachment['url'] ) ) {
|
if ( ! empty( $attachment['url'] ) ) {
|
||||||
$rel = '';
|
$rel = '';
|
||||||
|
@ -450,7 +450,8 @@
|
|||||||
return media.post( 'send-attachment-to-editor', {
|
return media.post( 'send-attachment-to-editor', {
|
||||||
nonce: wp.media.view.settings.nonce.sendToEditor,
|
nonce: wp.media.view.settings.nonce.sendToEditor,
|
||||||
attachment: options,
|
attachment: options,
|
||||||
html: html
|
html: html,
|
||||||
|
post_id: wp.media.view.settings.postId
|
||||||
}).done( function( resp ) {
|
}).done( function( resp ) {
|
||||||
wp.media.editor.insert( resp );
|
wp.media.editor.insert( resp );
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user