/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 22);
/************************************************************************/
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(23);
/***/ (function(module, exports, __webpack_require__) {
* @output wp-includes/js/media-models.js
Attachment, Attachments, l10n, media;
window.wp = window.wp || {};
* Create and return a media frame.
* Handles the default media experience.
* @param {Object} attributes The properties passed to the main media controller.
* @return {wp.media.view.MediaFrame} A media workflow.
media = wp.media = function( attributes ) {
var MediaFrame = media.view.MediaFrame,
attributes = _.defaults( attributes || {}, {
if ( 'select' === attributes.frame && MediaFrame.Select ) {
frame = new MediaFrame.Select( attributes );
} else if ( 'post' === attributes.frame && MediaFrame.Post ) {
frame = new MediaFrame.Post( attributes );
} else if ( 'manage' === attributes.frame && MediaFrame.Manage ) {
frame = new MediaFrame.Manage( attributes );
} else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) {
frame = new MediaFrame.ImageDetails( attributes );
} else if ( 'audio' === attributes.frame && MediaFrame.AudioDetails ) {
frame = new MediaFrame.AudioDetails( attributes );
} else if ( 'video' === attributes.frame && MediaFrame.VideoDetails ) {
frame = new MediaFrame.VideoDetails( attributes );
} else if ( 'edit-attachments' === attributes.frame && MediaFrame.EditAttachments ) {
frame = new MediaFrame.EditAttachments( attributes );
/** @namespace wp.media.model */
/** @namespace wp.media.view */
/** @namespace wp.media.controller */
/** @namespace wp.media.frames */
_.extend( media, { model: {}, view: {}, controller: {}, frames: {} });
// Link any localized strings.
l10n = media.model.l10n = window._wpMediaModelsL10n || {};
media.model.settings = l10n.settings || {};
Attachment = media.model.Attachment = __webpack_require__( 24 );
Attachments = media.model.Attachments = __webpack_require__( 25 );
media.model.Query = __webpack_require__( 26 );
media.model.PostImage = __webpack_require__( 27 );
media.model.Selection = __webpack_require__( 28 );
* ========================================================================
* ========================================================================
* A basic equality comparator for Backbone models.
* Used to order models within a collection - @see wp.media.model.Attachments.comparator().
* @param {mixed} a The primary parameter to compare.
* @param {mixed} b The primary parameter to compare.
* @param {string} ac The fallback parameter to compare, a's cid.
* @param {string} bc The fallback parameter to compare, b's cid.
* @return {number} -1: a should come before b.
* 0: a and b are of the same rank.
* 1: b should come before a.
media.compare = function( a, b, ac, bc ) {
if ( _.isEqual( a, b ) ) {
return ac === bc ? 0 : (ac > bc ? -1 : 1);
_.extend( media, /** @lends wp.media */{
* Fetch a JavaScript template for an id, and return a templating function for it.
* See wp.template() in `wp-includes/js/wp-util.js`.
* @borrows wp.template as template
* media.post( [action], [data] )
* Sends a POST request to WordPress.
* See wp.ajax.post() in `wp-includes/js/wp-util.js`.
* @borrows wp.ajax.post as post
* media.ajax( [action], [options] )
* Sends an XHR request to WordPress.
* See wp.ajax.send() in `wp-includes/js/wp-util.js`.
* @borrows wp.ajax.send as ajax
* Scales a set of dimensions to fit within bounding dimensions.
* @param {Object} dimensions
fit: function( dimensions ) {
var width = dimensions.width,
height = dimensions.height,
maxWidth = dimensions.maxWidth,
maxHeight = dimensions.maxHeight,
* Compare ratios between the two values to determine
* which max to constrain by. If a max value doesn't exist,
* then the opposite side is the constraint.
if ( ! _.isUndefined( maxWidth ) && ! _.isUndefined( maxHeight ) ) {
constraint = ( width / height > maxWidth / maxHeight ) ? 'width' : 'height';
} else if ( _.isUndefined( maxHeight ) ) {
} else if ( _.isUndefined( maxWidth ) && height > maxHeight ) {
// If the value of the constrained side is larger than the max,
// then scale the values. Otherwise return the originals; they fit.
if ( 'width' === constraint && width > maxWidth ) {
height: Math.round( maxWidth * height / width )
} else if ( 'height' === constraint && height > maxHeight ) {
width : Math.round( maxHeight * width / height ),
* Truncates a string by injecting an ellipsis into the middle.
* @param {number} [length=30]
* @param {string} [replacement=…]
* @return {string} The string, unless length is greater than string.length.
truncate: function( string, length, replacement ) {
replacement = replacement || '…';
if ( string.length <= length ) {
return string.substr( 0, length / 2 ) + replacement + string.substr( -1 * length / 2 );
* ========================================================================
* ========================================================================
* @param {string} id A string used to identify a model.
* @return {wp.media.model.Attachment}
media.attachment = function( id ) {
return Attachment.get( id );
* A collection of all attachments that have been fetched from the server.
* @member {wp.media.model.Attachments}
Attachments.all = new Attachments();
* Shorthand for creating a new Attachments Query.
* @param {Object} [props]
* @return {wp.media.model.Attachments}
media.query = function( props ) {
return new Attachments( null, {
props: _.extend( _.defaults( props || {}, { orderby: 'date' } ), { query: true } )
// Clean up. Prevents mobile browsers caching.
$(window).on('unload', function(){
/***/ (function(module, exports) {
* wp.media.model.Attachment
* @memberOf wp.media.model
* @augments Backbone.Model
Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototype */{
* Triggered when attachment details change
* Overrides Backbone.Model.sync
* @param {wp.media.model.Attachment} model
* @param {Object} [options={}]
sync: function( method, model, options ) {
// If the attachment does not yet have an `id`, return an instantly
// rejected promise. Otherwise, all of our requests will fail.
if ( _.isUndefined( this.id ) ) {
return $.Deferred().rejectWith( this ).promise();
// Overload the `read` request so Attachment.fetch() functions correctly.
if ( 'read' === method ) {
options.data = _.extend( options.data || {}, {
action: 'get-attachment',
return wp.media.ajax( options );
// Overload the `update` request so properties can be saved.
} else if ( 'update' === method ) {
// If we do not have the necessary nonce, fail immediately.
if ( ! this.get('nonces') || ! this.get('nonces').update ) {
return $.Deferred().rejectWith( this ).promise();
// Set the action and ID.
options.data = _.extend( options.data || {}, {
action: 'save-attachment',
nonce: this.get('nonces').update,
post_id: wp.media.model.settings.post.id
// Record the values of the changed attributes.
if ( model.hasChanged() ) {
options.data.changes = {};
_.each( model.changed, function( value, key ) {
options.data.changes[ key ] = this.get( key );
return wp.media.ajax( options );
// Overload the `delete` request so attachments can be removed.
// This will permanently delete an attachment.
} else if ( 'delete' === method ) {
options.data = _.extend( options.data || {}, {
_wpnonce: this.get('nonces')['delete']
return wp.media.ajax( options ).done( function() {
// Otherwise, fall back to `Backbone.sync()`.
* Call `sync` directly on Backbone.Model
return Backbone.Model.prototype.sync.apply( this, arguments );
* Convert date strings into Date objects.
* @param {Object} resp The raw response object, typically returned by fetch()
* @return {Object} The modified response object, which is the attributes hash
* to be set on the model.
parse: function( resp ) {
resp.date = new Date( resp.date );
resp.modified = new Date( resp.modified );
* @param {Object} data The properties to be saved.
* @param {Object} options Sync options. e.g. patch, wait, success, error.
saveCompat: function( data, options ) {
// If we do not have the necessary nonce, fail immediately.
if ( ! this.get('nonces') || ! this.get('nonces').update ) {
return $.Deferred().rejectWith( this ).promise();
return wp.media.post( 'save-attachment-compat', _.defaults({
nonce: this.get('nonces').update,
post_id: wp.media.model.settings.post.id
}, data ) ).done( function( resp, status, xhr ) {
model.set( model.parse( resp, xhr ), options );
},/** @lends wp.media.model.Attachment */{
* Create a new model on the static 'all' attachments collection and return it.
* @return {wp.media.model.Attachment}
create: function( attrs ) {
var Attachments = wp.media.model.Attachments;
return Attachments.all.push( attrs );