[wp-trac] [WordPress Trac] #29689: Drag-and-drop media upload fails if the Media Library has already been opened and closed manually

WordPress Trac noreply at wordpress.org
Mon Oct 13 17:22:21 UTC 2014


#29689: Drag-and-drop media upload fails if the Media Library has already been
opened and closed manually
--------------------------+-------------------------
 Reporter:  cfinke        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.1
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  javascript
--------------------------+-------------------------

Comment (by danielpataki):

 I've figured out where the issue is but I am less of a Javascript ninja
 than I should be so if someone would lend a hand that would be great!

 In wp-includes/js/media-views.js, in the drop function in
 media.view.EditorUploader if there is no workflow set the workflow is
 created. Once created the image is added like this:

 {{{
 this.workflow.on( 'uploader:ready', this.addFiles, this );
 }}}

 If this is replaced by the following it works just fine:

 {{{
 this.addFiles.apply( this );
 }}}

 Since I am not too familiar with these parts of WordPress I am worried
 that the listener is there for a reason. Some debugging suggests that
 there is no need for this listener but I am definitely not sure.

 In addition, I don't know if the other workflow methods need to be used.
 If yes, the whole section could be simplified like so:

 {{{
 if ( ! this.workflow ) {
         this.workflow = wp.media.editor.open( 'content', {
                 frame:    'post',
                 state:    'insert',
                 title:    wp.media.view.l10n.addMedia,
                 multiple: true
         });
 this.workflow.state().reset();
 this.addFiles.apply( this );
 this.workflow.open();
 }}}

 I am not submitting a patch at the moment since I'm not sure which route
 is correct. Perhaps somewhere the ready event isn't being triggered even
 though it should?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29689#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list