Make WordPress Core

Changeset 29759


Ignore:
Timestamp:
09/23/2014 03:37:06 AM (10 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-models.js

    r29531 r29759  
    11651165            'menuOrder': 'menu_order',
    11661166            'uploadedTo': 'post_parent',
    1167             'status':     'post_status'
     1167            'status':     'post_status',
     1168            'include':    'post__in',
     1169            'exclude':    'post__not_in'
    11681170        },
    11691171        /**
     
    12121214                }
    12131215
     1216                _.each( [ 'include', 'exclude' ], function( prop ) {
     1217                    if ( props[ prop ] && ! _.isArray( props[ prop ] ) ) {
     1218                        props[ prop ] = [ props[ prop ] ];
     1219                    }
     1220                } );
     1221
    12141222                // Generate the query `args` object.
    12151223                // Correct any differing property names.
Note: See TracChangeset for help on using the changeset viewer.