Fix race condition in media insertion where the inserted html is invalid due to output being interleaved.
Props koopermsith fixes #22696 git-svn-id: http://core.svn.wordpress.org/trunk@23012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6b1a66ac22
commit
cbf378b601
|
@ -397,10 +397,12 @@
|
||||||
if ( ! selection )
|
if ( ! selection )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selection.each( function( attachment ) {
|
$.when.apply( $, selection.map( function( attachment ) {
|
||||||
var display = state.display( attachment ).toJSON();
|
var display = state.display( attachment ).toJSON();
|
||||||
this.send.attachment( display, attachment.toJSON() );
|
return this.send.attachment( display, attachment.toJSON() );
|
||||||
}, this );
|
}, this ) ).done( function() {
|
||||||
|
wp.media.editor.insert( _.toArray( arguments ).join('') );
|
||||||
|
});
|
||||||
}, this );
|
}, this );
|
||||||
|
|
||||||
workflow.state('gallery-edit').on( 'update', function( selection ) {
|
workflow.state('gallery-edit').on( 'update', function( selection ) {
|
||||||
|
@ -420,7 +422,9 @@
|
||||||
linkUrl: embed.url
|
linkUrl: embed.url
|
||||||
});
|
});
|
||||||
|
|
||||||
this.send.link( embed );
|
this.send.link( embed ).done( function( resp ) {
|
||||||
|
wp.media.editor.insert( resp );
|
||||||
|
});
|
||||||
|
|
||||||
} else if ( 'image' === type ) {
|
} else if ( 'image' === type ) {
|
||||||
_.defaults( embed, {
|
_.defaults( embed, {
|
||||||
|
@ -528,8 +532,6 @@
|
||||||
attachment: options,
|
attachment: options,
|
||||||
html: html,
|
html: html,
|
||||||
post_id: wp.media.view.settings.post.id
|
post_id: wp.media.view.settings.post.id
|
||||||
}).done( function( resp ) {
|
|
||||||
wp.media.editor.insert( resp );
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -540,8 +542,6 @@
|
||||||
title: embed.title,
|
title: embed.title,
|
||||||
html: wp.media.string.link( embed ),
|
html: wp.media.string.link( embed ),
|
||||||
post_id: wp.media.view.settings.post.id
|
post_id: wp.media.view.settings.post.id
|
||||||
}).done( function( resp ) {
|
|
||||||
wp.media.editor.insert( resp );
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue