Opened 10 years ago
Closed 10 years ago
#29689 closed defect (bug) (fixed)
Drag-and-drop media upload fails if the Media Library has already been opened and closed manually
Reported by: | cfinke | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Media | Keywords: | needs-patch |
Focuses: | javascript | Cc: |
Description
What I Did
- Created a new post by visiting
wp-admin/post-new.php
- Clicked the "Add Media" button.
- Closed the Media Library by clicking on the "X" in the top right corner.
- Dragged and dropped an image file from my desktop into the editor.
What I Expected
That the image file would upload and appear in the Media Library.
What Happened
The Media Library overlay opened, but no upload occurred.
Notes
This bug only affects the first attempt during any given pageload to upload via drag-and-drop into the editor after the Media Library has been opened. Subsequent drag-and-drop uploads completed without issue.
Dragging and dropping into the Media Library is not affected, just into the editor.
Browsers: Firefox 32 and 33 on Mac OS X 10.9.4
Reproduced in WordPress 4.0 and today's nightly build with no plugins active.
Change History (4)
#2
@
10 years ago
- Focuses javascript added
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.1
Reproduced.
#3
@
10 years ago
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?
I reproduced it on 4.0 and trunk.