When settting a featured image, move the currently selected image to the beginning of the library if it doesn't exist within the attachments loaded so far.
Props koopersmith fixes #22494 git-svn-id: https://develop.svn.wordpress.org/trunk@22993 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
077dea75f7
commit
594bbe90df
|
@ -575,11 +575,34 @@
|
||||||
}, media.controller.Library.prototype.defaults ),
|
}, media.controller.Library.prototype.defaults ),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
var library, comparator;
|
||||||
|
|
||||||
// If we haven't been provided a `library`, create a `Selection`.
|
// If we haven't been provided a `library`, create a `Selection`.
|
||||||
if ( ! this.get('library') )
|
if ( ! this.get('library') )
|
||||||
this.set( 'library', media.query({ type: 'image' }) );
|
this.set( 'library', media.query({ type: 'image' }) );
|
||||||
|
|
||||||
media.controller.Library.prototype.initialize.apply( this, arguments );
|
media.controller.Library.prototype.initialize.apply( this, arguments );
|
||||||
|
|
||||||
|
library = this.get('library');
|
||||||
|
comparator = library.comparator;
|
||||||
|
|
||||||
|
// Overload the library's comparator to push items that are not in
|
||||||
|
// the mirrored query to the front of the aggregate collection.
|
||||||
|
library.comparator = function( a, b ) {
|
||||||
|
var aInQuery = !! this.mirroring.getByCid( a.cid ),
|
||||||
|
bInQuery = !! this.mirroring.getByCid( b.cid );
|
||||||
|
|
||||||
|
if ( ! aInQuery && bInQuery )
|
||||||
|
return -1;
|
||||||
|
else if ( aInQuery && ! bInQuery )
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return comparator.apply( this, arguments );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add all items in the selection to the library, so any featured
|
||||||
|
// images that are not initially loaded still appear.
|
||||||
|
library.observe( this.get('selection') );
|
||||||
},
|
},
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
|
|
Loading…
Reference in New Issue