From 46bc46d88a6cccf3a07876a8812e2784b250998d Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 21 Nov 2012 08:17:45 +0000 Subject: [PATCH] Media: Dropping images on the edit gallery view will automatically add those images to the gallery. fixes #22521, see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@22738 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 8f51902001..0081337635 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -311,7 +311,7 @@ // from the selection. this.get('selection').off( null, null, this ); - wp.Uploader.queue.off( 'add', this.selectUpload, this ); + wp.Uploader.queue.off( null, null, this ); this.off( 'change:excludeState', this._excludeState, this ); this.off( 'change:library change:exclude', this.buildComposite, this ); @@ -500,6 +500,25 @@ media.controller.Library.prototype.initialize.apply( this, arguments ); }, + activate: function() { + var library = this.get('library'); + + // Limit the library to images only. + library.props.set( 'type', 'image' ); + console.log('set', library.props.toJSON(), library.filters ); + + // Watch for uploaded attachments. + this.get('library').observe( wp.Uploader.queue ); + + media.controller.Library.prototype.activate.apply( this, arguments ); + }, + + deactivate: function() { + // Stop watching for uploaded attachments. + this.get('library').unobserve( wp.Uploader.queue ); + media.controller.Library.prototype.deactivate.apply( this, arguments ); + }, + sidebar: function() { media.controller.Library.prototype.sidebar.apply( this, arguments ); this.frame.sidebar.trigger('gallery-settings');