Add two properties to media.model.Attachments.propmap: include and exclude, which are aliases for post__in and post__not_in.

This allows you to instantiate a library that includes and/or excludes specific attachments by passing a single ID or an array of IDs.

Example usage:
{{{
wp.media({frame: 'post', library: {include: [414, 415]}}).open()
wp.media({frame: 'post', library: {include: 414}}).open()
wp.media({frame: 'post', library: {exclude: [414, 415]}}).open()
wp.media({frame: 'post', library: {exclude: 414}}).open()
}}}

Fixes #26587.


git-svn-id: https://develop.svn.wordpress.org/trunk@29759 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-09-23 03:37:06 +00:00
parent 22db82dff1
commit af71d22742

View File

@@ -1164,7 +1164,9 @@ window.wp = window.wp || {};
'perPage': 'posts_per_page',
'menuOrder': 'menu_order',
'uploadedTo': 'post_parent',
'status': 'post_status'
'status': 'post_status',
'include': 'post__in',
'exclude': 'post__not_in'
},
/**
* @static
@@ -1211,6 +1213,12 @@ window.wp = window.wp || {};
props.orderby = defaults.orderby;
}
_.each( [ 'include', 'exclude' ], function( prop ) {
if ( props[ prop ] && ! _.isArray( props[ prop ] ) ) {
props[ prop ] = [ props[ prop ] ];
}
} );
// Generate the query `args` object.
// Correct any differing property names.
_.each( props, function( value, prop ) {