| 1 | Index: wp-includes/js/media-editor.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/media-editor.js (revision 23006) |
|---|
| 4 | +++ wp-includes/js/media-editor.js (working copy) |
|---|
| 5 | @@ -397,10 +397,12 @@ |
|---|
| 6 | if ( ! selection ) |
|---|
| 7 | return; |
|---|
| 8 | |
|---|
| 9 | - selection.each( function( attachment ) { |
|---|
| 10 | + $.when.apply( $, selection.map( function( attachment ) { |
|---|
| 11 | var display = state.display( attachment ).toJSON(); |
|---|
| 12 | - this.send.attachment( display, attachment.toJSON() ); |
|---|
| 13 | - }, this ); |
|---|
| 14 | + return this.send.attachment( display, attachment.toJSON() ); |
|---|
| 15 | + }, this ) ).done( function() { |
|---|
| 16 | + wp.media.editor.insert( _.toArray( arguments ).join('') ); |
|---|
| 17 | + }); |
|---|
| 18 | }, this ); |
|---|
| 19 | |
|---|
| 20 | workflow.state('gallery-edit').on( 'update', function( selection ) { |
|---|
| 21 | @@ -420,7 +422,9 @@ |
|---|
| 22 | linkUrl: embed.url |
|---|
| 23 | }); |
|---|
| 24 | |
|---|
| 25 | - this.send.link( embed ); |
|---|
| 26 | + this.send.link( embed ).done( function( resp ) { |
|---|
| 27 | + wp.media.editor.insert( resp ); |
|---|
| 28 | + }); |
|---|
| 29 | |
|---|
| 30 | } else if ( 'image' === type ) { |
|---|
| 31 | _.defaults( embed, { |
|---|
| 32 | @@ -528,8 +532,6 @@ |
|---|
| 33 | attachment: options, |
|---|
| 34 | html: html, |
|---|
| 35 | post_id: wp.media.view.settings.post.id |
|---|
| 36 | - }).done( function( resp ) { |
|---|
| 37 | - wp.media.editor.insert( resp ); |
|---|
| 38 | }); |
|---|
| 39 | }, |
|---|
| 40 | |
|---|
| 41 | @@ -540,8 +542,6 @@ |
|---|
| 42 | title: embed.title, |
|---|
| 43 | html: wp.media.string.link( embed ), |
|---|
| 44 | post_id: wp.media.view.settings.post.id |
|---|
| 45 | - }).done( function( resp ) { |
|---|
| 46 | - wp.media.editor.insert( resp ); |
|---|
| 47 | }); |
|---|
| 48 | } |
|---|
| 49 | }, |
|---|