mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-04 18:01:42 +01:00
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: http://core.svn.wordpress.org/trunk@22993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8ca0066e3a
commit
0848a51955
@ -575,11 +575,34 @@
|
||||
}, media.controller.Library.prototype.defaults ),
|
||||
|
||||
initialize: function() {
|
||||
var library, comparator;
|
||||
|
||||
// If we haven't been provided a `library`, create a `Selection`.
|
||||
if ( ! this.get('library') )
|
||||
this.set( 'library', media.query({ type: 'image' }) );
|
||||
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user