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.

Built from https://develop.svn.wordpress.org/trunk@29759


git-svn-id: http://core.svn.wordpress.org/trunk@29531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-09-23 03:38:16 +00:00
parent 2f328cc4c1
commit e3eaed1c78
2 changed files with 10 additions and 2 deletions

View File

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

File diff suppressed because one or more lines are too long