Skip to content

Commit

Permalink
Fix cloning group copies previous image_advanced
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed Jun 27, 2019
1 parent 3b668d6 commit 03df0e3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions js/media.js
Expand Up @@ -126,14 +126,8 @@ jQuery( function ( $ ) {
this.createAddButton();
this.createStatus();

// Render
this.render();

// Load initial attachments.
var models = this.$input.data( 'attachments' ).map( function( attachment ) {
return wp.media.model.Attachment.create( attachment );
} );
this.controller.get( 'items' ).add( models );
this.loadInitialAttachments();

// Listen for destroy event on input
this.$input.on( 'remove', function () {
Expand All @@ -153,6 +147,16 @@ jQuery( function ( $ ) {
}, 500 ) );
},

loadInitialAttachments: function () {
if ( ! this.$input.val() ) {
return;
}
var models = this.$input.data( 'attachments' ).map( function( attachment ) {
return wp.media.model.Attachment.create( attachment );
} );
this.controller.get( 'items' ).add( models );
},

// Creates media list
createList: function () {
this.list = new MediaList( {controller: this.controller} );
Expand Down Expand Up @@ -272,7 +276,7 @@ jQuery( function ( $ ) {
frameContent.collection.more();
}
}, this );

this._switchFrame.on( 'select', function () {
var selection = this._switchFrame.state().get( 'selection' ),
collection = this.collection,
Expand Down Expand Up @@ -370,12 +374,12 @@ jQuery( function ( $ ) {
// Refresh content when frame opens
this._frame.on( 'open', function() {
var frameContent = this._frame.content.get();
if ( frameContent && frameContent.collection ) {
if ( frameContent && frameContent.collection ) {
frameContent.collection.mirroring._hasMore = true;
frameContent.collection.more();
}
}, this );

this._frame.on( 'select', function () {
var selection = this._frame.state().get( 'selection' );
this.collection.add( selection.models );
Expand Down

0 comments on commit 03df0e3

Please sign in to comment.