WordPress.org

Make WordPress Core

Changeset 22022


Ignore:
Timestamp:
09/26/2012 09:40:02 PM (7 years ago)
Author:
koopersmith
Message:

Limit the featured image workflow to images only.

Adds the ability to set the values used to instantiate both the Workflow's library and selection.
Renames the Workflows internal _pending variable to prevent conflicts with a similarly named internal Backbone.Model variable.

see #21390, #21776.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/meta-boxes.php

    r22019 r22022  
    10311031
    10321032            if ( ! workflow ) {
    1033                 workflow = wp.media();
     1033                workflow = wp.media({
     1034                    library: {
     1035                        type: 'image'
     1036                    }
     1037                });
     1038
    10341039                workflow.selection.on( 'add', function( model ) {
    10351040                    var sizes = model.get('sizes'),
  • trunk/wp-includes/js/media-views.js

    r21908 r22022  
    1717    media.controller.Workflow = Backbone.Model.extend({
    1818        defaults: {
    19             multiple: false,
    20             view:     'library'
     19            multiple:  false,
     20            view:      'library',
     21            library:   {},
     22            selection: []
    2123        },
    2224
     
    2527
    2628            // Initialize view storage.
    27             this._views   = {};
    28             this._pending = {};
     29            this._views        = {};
     30            this._pendingViews = {};
    2931
    3032            // Initialize modal container view.
     
    3234
    3335            // Add default views.
    34             this.add( 'library', media.view.Workspace.Library, { collection: media.query() } );
     36            //
     37            // Use the `library` property to initialize the corresponding view,
     38            // then unset the property.
     39            this.add( 'library', media.view.Workspace.Library, {
     40                collection: media.query( this.get('library') )
     41            } );
     42            this.unset('library');
     43
     44            // Add the gallery view.
    3545            this.add( 'gallery', media.view.Workspace.Gallery, { collection: this.selection } );
    3646        },
     
    4656        add: function( id, constructor, options ) {
    4757            this.remove( id );
    48             this._pending[ id ] = {
     58            this._pendingViews[ id ] = {
    4959                view:    constructor,
    5060                options: options
     
    6474
    6575            id = id || this.get('view');
    66             pending = this._pending[ id ];
     76            pending = this._pendingViews[ id ];
    6777
    6878            if ( ! this._views[ id ] && pending ) {
    6979                this._views[ id ] = new pending.view( _.extend({ controller: this }, pending.options || {} ) );
    70                 delete this._pending[ id ];
     80                delete this._pendingViews[ id ];
    7181                this.trigger( 'init init:' + id, this._views[ id ] );
    7282            }
     
    8090        remove: function( id ) {
    8191            delete this._views[ id ];
    82             delete this._pending[ id ];
     92            delete this._pendingViews[ id ];
    8393            this.trigger( 'remove remove:' + id );
    8494            return this;
     
    97107
    98108            if ( ! view )
    99                 return;
     109                return this;
    100110
    101111            view.render();
     
    108118
    109119            // Initialize workflow-specific models.
    110             this.selection = new Attachments();
     120            // Use the `selection` property to initialize the Attachments
     121            // collection, then unset the property.
     122            this.selection = new Attachments( this.get('selection') );
     123            this.unset('selection');
    111124
    112125            _.extend( this.selection, {
Note: See TracChangeset for help on using the changeset viewer.