Widgets: Prevent multiple items from being selectable when first populating a media widget.

Amends [40640].
Props obenland, timmydcrawford.
See #32417.


git-svn-id: https://develop.svn.wordpress.org/trunk@40827 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-05-24 05:31:00 +00:00
parent f8dabb5b35
commit 6d02212d57
1 changed files with 4 additions and 4 deletions

View File

@ -640,14 +640,14 @@ wp.mediaWidgets = ( function( $ ) {
* @returns {void}
*/
selectMedia: function selectMedia() {
var control = this, selection, mediaFrame, defaultSync, mediaFrameProps;
var control = this, selection, mediaFrame, defaultSync, mediaFrameProps, selectionModels = [];
if ( control.isSelected() && 0 !== control.model.get( 'attachment_id' ) ) {
selection = new wp.media.model.Selection([ control.selectedAttachment ]);
} else {
selection = null;
selectionModels.push( control.selectedAttachment );
}
selection = new wp.media.model.Selection( selectionModels, { multiple: false } );
mediaFrameProps = control.mapModelToMediaFrameProps( control.model.toJSON() );
if ( mediaFrameProps.size ) {
control.displaySettings.set( 'size', mediaFrameProps.size );