Media: Update total attachment count when media added or removed.
Add handlers to increment the total attachments count for the media collection when an item is added or removed. props adamsilverstein. Fixes #53171. Built from https://develop.svn.wordpress.org/trunk@51191 git-svn-id: http://core.svn.wordpress.org/trunk@50800 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -591,6 +591,8 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
this.observers.push( attachments );
|
||||
|
||||
attachments.on( 'add change remove', this._validateHandler, this );
|
||||
attachments.on( 'add', this._addToTotalAttachments, this );
|
||||
attachments.on( 'remove', this._removeFromTotalAttachments, this );
|
||||
attachments.on( 'reset', this._validateAllHandler, this );
|
||||
this.validateAll( attachments );
|
||||
return this;
|
||||
@@ -615,6 +617,30 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
* Update total attachment count when items are added to a collection.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 5.8.0
|
||||
*/
|
||||
_removeFromTotalAttachments: function() {
|
||||
if ( this.mirroring ) {
|
||||
this.mirroring.totalAttachments = this.mirroring.totalAttachments - 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Update total attachment count when items are added to a collection.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 5.8.0
|
||||
*/
|
||||
_addToTotalAttachments: function() {
|
||||
if ( this.mirroring ) {
|
||||
this.mirroring.totalAttachments = this.mirroring.totalAttachments + 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
|
||||
2
wp-includes/js/media-models.min.js
vendored
2
wp-includes/js/media-models.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-beta2-51190';
|
||||
$wp_version = '5.8-beta2-51191';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user