diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index bb2c949c73..ae9ea8e1d0 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -7724,9 +7724,11 @@ Toolbar = View.extend({ disabled = false; // Prevent insertion of attachments if any of them are still uploading - disabled = _.some( selection.models, function( attachment ) { - return attachment.get('uploading') === true; - }); + if ( selection && selection.models ) { + disabled = _.some( selection.models, function( attachment ) { + return attachment.get('uploading') === true; + }); + } if ( requires.selection && selection && ! selection.length ) { disabled = true; diff --git a/src/wp-includes/js/media/views/toolbar.js b/src/wp-includes/js/media/views/toolbar.js index 7884a4b02d..e1884bf0a6 100644 --- a/src/wp-includes/js/media/views/toolbar.js +++ b/src/wp-includes/js/media/views/toolbar.js @@ -141,9 +141,11 @@ Toolbar = View.extend({ disabled = false; // Prevent insertion of attachments if any of them are still uploading - disabled = _.some( selection.models, function( attachment ) { - return attachment.get('uploading') === true; - }); + if ( selection && selection.models ) { + disabled = _.some( selection.models, function( attachment ) { + return attachment.get('uploading') === true; + }); + } if ( requires.selection && selection && ! selection.length ) { disabled = true;