Make WordPress Core

Changeset 21692


Ignore:
Timestamp:
08/31/2012 08:44:02 PM (13 years ago)
Author:
koopersmith
Message:

Add wp.media(), a function to create a default media workflow.

This will be the main entry point for basic media development, and should hopefully help less experienced developers wrangle the new media APIs.

If you would like to see the new UI, navigate to the post editor and run the following in your browser's Javascript console:

wp.media();

Well, that certainly feels a lot nicer to type.

see #21390.

File:
1 edited

Legend:

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

    r21689 r21692  
    33
    44(function($){
    5     var media = wp.media = { model: {}, view: {}, controller: {} },
    6         Attachment, Attachments, Query;
     5    var Attachment, Attachments, Query;
     6
     7    /**
     8     * wp.media( attributes )
     9     *
     10     * Handles the default media experience. Automatically creates
     11     * and opens a media workflow, and returns the result.
     12     * Does nothing if the controllers do not exist.
     13     *
     14     * @param  {object} attributes The properties passed to the main media controller.
     15     * @return {object}            A media workflow.
     16     */
     17    media = wp.media = function( attributes ) {
     18        if ( media.controller.Workflow )
     19            return new media.controller.Workflow( attributes ).render();
     20    };
     21
     22    _.extend( media, { model: {}, view: {}, controller: {} });
    723
    824    /**
Note: See TracChangeset for help on using the changeset viewer.