mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-21 23:11:53 +01:00
Build: Use deterministic module ids in webpack for media
Follow-up for [50940]. Props peterwilsoncc. See #53192. Built from https://develop.svn.wordpress.org/trunk@50984 git-svn-id: http://core.svn.wordpress.org/trunk@50593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cfa7f89ba0
commit
2597902bc0
@ -84,15 +84,9 @@
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
/******/ ({
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 1 */
|
||||
/***/ "./src/js/_enqueues/wp/media/audiovideo.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
/**
|
||||
@ -370,19 +364,100 @@ wp.media.video = {
|
||||
}
|
||||
};
|
||||
|
||||
media.model.PostMedia = __webpack_require__( 2 );
|
||||
media.controller.AudioDetails = __webpack_require__( 3 );
|
||||
media.controller.VideoDetails = __webpack_require__( 4 );
|
||||
media.view.MediaFrame.MediaDetails = __webpack_require__( 5 );
|
||||
media.view.MediaFrame.AudioDetails = __webpack_require__( 6 );
|
||||
media.view.MediaFrame.VideoDetails = __webpack_require__( 7 );
|
||||
media.view.MediaDetails = __webpack_require__( 8 );
|
||||
media.view.AudioDetails = __webpack_require__( 9 );
|
||||
media.view.VideoDetails = __webpack_require__( 10 );
|
||||
media.model.PostMedia = __webpack_require__( "./src/js/media/models/post-media.js" );
|
||||
media.controller.AudioDetails = __webpack_require__( "./src/js/media/controllers/audio-details.js" );
|
||||
media.controller.VideoDetails = __webpack_require__( "./src/js/media/controllers/video-details.js" );
|
||||
media.view.MediaFrame.MediaDetails = __webpack_require__( "./src/js/media/views/frame/media-details.js" );
|
||||
media.view.MediaFrame.AudioDetails = __webpack_require__( "./src/js/media/views/frame/audio-details.js" );
|
||||
media.view.MediaFrame.VideoDetails = __webpack_require__( "./src/js/media/views/frame/video-details.js" );
|
||||
media.view.MediaDetails = __webpack_require__( "./src/js/media/views/media-details.js" );
|
||||
media.view.AudioDetails = __webpack_require__( "./src/js/media/views/audio-details.js" );
|
||||
media.view.VideoDetails = __webpack_require__( "./src/js/media/views/video-details.js" );
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 2 */
|
||||
|
||||
/***/ "./src/js/media/controllers/audio-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var State = wp.media.controller.State,
|
||||
l10n = wp.media.view.l10n,
|
||||
AudioDetails;
|
||||
|
||||
/**
|
||||
* wp.media.controller.AudioDetails
|
||||
*
|
||||
* The controller for the Audio Details state
|
||||
*
|
||||
* @memberOf wp.media.controller
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.controller.State
|
||||
* @augments Backbone.Model
|
||||
*/
|
||||
AudioDetails = State.extend(/** @lends wp.media.controller.AudioDetails.prototype */{
|
||||
defaults: {
|
||||
id: 'audio-details',
|
||||
toolbar: 'audio-details',
|
||||
title: l10n.audioDetailsTitle,
|
||||
content: 'audio-details',
|
||||
menu: 'audio-details',
|
||||
router: false,
|
||||
priority: 60
|
||||
},
|
||||
|
||||
initialize: function( options ) {
|
||||
this.media = options.media;
|
||||
State.prototype.initialize.apply( this, arguments );
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = AudioDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/js/media/controllers/video-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/**
|
||||
* wp.media.controller.VideoDetails
|
||||
*
|
||||
* The controller for the Video Details state
|
||||
*
|
||||
* @memberOf wp.media.controller
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.controller.State
|
||||
* @augments Backbone.Model
|
||||
*/
|
||||
var State = wp.media.controller.State,
|
||||
l10n = wp.media.view.l10n,
|
||||
VideoDetails;
|
||||
|
||||
VideoDetails = State.extend(/** @lends wp.media.controller.VideoDetails.prototype */{
|
||||
defaults: {
|
||||
id: 'video-details',
|
||||
toolbar: 'video-details',
|
||||
title: l10n.videoDetailsTitle,
|
||||
content: 'video-details',
|
||||
menu: 'video-details',
|
||||
router: false,
|
||||
priority: 60
|
||||
},
|
||||
|
||||
initialize: function( options ) {
|
||||
this.media = options.media;
|
||||
State.prototype.initialize.apply( this, arguments );
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = VideoDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/js/media/models/post-media.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/**
|
||||
@ -430,38 +505,44 @@ module.exports = PostMedia;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 3 */
|
||||
|
||||
/***/ "./src/js/media/views/audio-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var State = wp.media.controller.State,
|
||||
l10n = wp.media.view.l10n,
|
||||
var MediaDetails = wp.media.view.MediaDetails,
|
||||
AudioDetails;
|
||||
|
||||
/**
|
||||
* wp.media.controller.AudioDetails
|
||||
* wp.media.view.AudioDetails
|
||||
*
|
||||
* The controller for the Audio Details state
|
||||
*
|
||||
* @memberOf wp.media.controller
|
||||
* @memberOf wp.media.view
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.controller.State
|
||||
* @augments Backbone.Model
|
||||
* @augments wp.media.view.MediaDetails
|
||||
* @augments wp.media.view.Settings.AttachmentDisplay
|
||||
* @augments wp.media.view.Settings
|
||||
* @augments wp.media.View
|
||||
* @augments wp.Backbone.View
|
||||
* @augments Backbone.View
|
||||
*/
|
||||
AudioDetails = State.extend(/** @lends wp.media.controller.AudioDetails.prototype */{
|
||||
defaults: {
|
||||
id: 'audio-details',
|
||||
toolbar: 'audio-details',
|
||||
title: l10n.audioDetailsTitle,
|
||||
content: 'audio-details',
|
||||
menu: 'audio-details',
|
||||
router: false,
|
||||
priority: 60
|
||||
},
|
||||
AudioDetails = MediaDetails.extend(/** @lends wp.media.view.AudioDetails.prototype */{
|
||||
className: 'audio-details',
|
||||
template: wp.template('audio-details'),
|
||||
|
||||
initialize: function( options ) {
|
||||
this.media = options.media;
|
||||
State.prototype.initialize.apply( this, arguments );
|
||||
setMedia: function() {
|
||||
var audio = this.$('.wp-audio-shortcode');
|
||||
|
||||
if ( audio.find( 'source' ).length ) {
|
||||
if ( audio.is(':hidden') ) {
|
||||
audio.show();
|
||||
}
|
||||
this.media = MediaDetails.prepareSrc( audio.get(0) );
|
||||
} else {
|
||||
audio.hide();
|
||||
this.media = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
@ -469,46 +550,91 @@ module.exports = AudioDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 4 */
|
||||
|
||||
/***/ "./src/js/media/views/frame/audio-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
|
||||
MediaLibrary = wp.media.controller.MediaLibrary,
|
||||
|
||||
l10n = wp.media.view.l10n,
|
||||
AudioDetails;
|
||||
|
||||
/**
|
||||
* wp.media.controller.VideoDetails
|
||||
* wp.media.view.MediaFrame.AudioDetails
|
||||
*
|
||||
* The controller for the Video Details state
|
||||
*
|
||||
* @memberOf wp.media.controller
|
||||
* @memberOf wp.media.view.MediaFrame
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.controller.State
|
||||
* @augments Backbone.Model
|
||||
* @augments wp.media.view.MediaFrame.MediaDetails
|
||||
* @augments wp.media.view.MediaFrame.Select
|
||||
* @augments wp.media.view.MediaFrame
|
||||
* @augments wp.media.view.Frame
|
||||
* @augments wp.media.View
|
||||
* @augments wp.Backbone.View
|
||||
* @augments Backbone.View
|
||||
* @mixes wp.media.controller.StateMachine
|
||||
*/
|
||||
var State = wp.media.controller.State,
|
||||
l10n = wp.media.view.l10n,
|
||||
VideoDetails;
|
||||
|
||||
VideoDetails = State.extend(/** @lends wp.media.controller.VideoDetails.prototype */{
|
||||
AudioDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.AudioDetails.prototype */{
|
||||
defaults: {
|
||||
id: 'video-details',
|
||||
toolbar: 'video-details',
|
||||
title: l10n.videoDetailsTitle,
|
||||
content: 'video-details',
|
||||
menu: 'video-details',
|
||||
router: false,
|
||||
priority: 60
|
||||
id: 'audio',
|
||||
url: '',
|
||||
menu: 'audio-details',
|
||||
content: 'audio-details',
|
||||
toolbar: 'audio-details',
|
||||
type: 'link',
|
||||
title: l10n.audioDetailsTitle,
|
||||
priority: 120
|
||||
},
|
||||
|
||||
initialize: function( options ) {
|
||||
this.media = options.media;
|
||||
State.prototype.initialize.apply( this, arguments );
|
||||
options.DetailsView = wp.media.view.AudioDetails;
|
||||
options.cancelText = l10n.audioDetailsCancel;
|
||||
options.addText = l10n.audioAddSourceTitle;
|
||||
|
||||
MediaDetails.prototype.initialize.call( this, options );
|
||||
},
|
||||
|
||||
bindHandlers: function() {
|
||||
MediaDetails.prototype.bindHandlers.apply( this, arguments );
|
||||
|
||||
this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
|
||||
this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
|
||||
},
|
||||
|
||||
createStates: function() {
|
||||
this.states.add([
|
||||
new wp.media.controller.AudioDetails( {
|
||||
media: this.media
|
||||
} ),
|
||||
|
||||
new MediaLibrary( {
|
||||
type: 'audio',
|
||||
id: 'replace-audio',
|
||||
title: l10n.audioReplaceTitle,
|
||||
toolbar: 'replace-audio',
|
||||
media: this.media,
|
||||
menu: 'audio-details'
|
||||
} ),
|
||||
|
||||
new MediaLibrary( {
|
||||
type: 'audio',
|
||||
id: 'add-audio-source',
|
||||
title: l10n.audioAddSourceTitle,
|
||||
toolbar: 'add-audio-source',
|
||||
media: this.media,
|
||||
menu: false
|
||||
} )
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = VideoDetails;
|
||||
module.exports = AudioDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 5 */
|
||||
|
||||
/***/ "./src/js/media/views/frame/media-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var Select = wp.media.view.MediaFrame.Select,
|
||||
@ -644,89 +770,8 @@ module.exports = MediaDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 6 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
|
||||
MediaLibrary = wp.media.controller.MediaLibrary,
|
||||
|
||||
l10n = wp.media.view.l10n,
|
||||
AudioDetails;
|
||||
|
||||
/**
|
||||
* wp.media.view.MediaFrame.AudioDetails
|
||||
*
|
||||
* @memberOf wp.media.view.MediaFrame
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.view.MediaFrame.MediaDetails
|
||||
* @augments wp.media.view.MediaFrame.Select
|
||||
* @augments wp.media.view.MediaFrame
|
||||
* @augments wp.media.view.Frame
|
||||
* @augments wp.media.View
|
||||
* @augments wp.Backbone.View
|
||||
* @augments Backbone.View
|
||||
* @mixes wp.media.controller.StateMachine
|
||||
*/
|
||||
AudioDetails = MediaDetails.extend(/** @lends wp.media.view.MediaFrame.AudioDetails.prototype */{
|
||||
defaults: {
|
||||
id: 'audio',
|
||||
url: '',
|
||||
menu: 'audio-details',
|
||||
content: 'audio-details',
|
||||
toolbar: 'audio-details',
|
||||
type: 'link',
|
||||
title: l10n.audioDetailsTitle,
|
||||
priority: 120
|
||||
},
|
||||
|
||||
initialize: function( options ) {
|
||||
options.DetailsView = wp.media.view.AudioDetails;
|
||||
options.cancelText = l10n.audioDetailsCancel;
|
||||
options.addText = l10n.audioAddSourceTitle;
|
||||
|
||||
MediaDetails.prototype.initialize.call( this, options );
|
||||
},
|
||||
|
||||
bindHandlers: function() {
|
||||
MediaDetails.prototype.bindHandlers.apply( this, arguments );
|
||||
|
||||
this.on( 'toolbar:render:replace-audio', this.renderReplaceToolbar, this );
|
||||
this.on( 'toolbar:render:add-audio-source', this.renderAddSourceToolbar, this );
|
||||
},
|
||||
|
||||
createStates: function() {
|
||||
this.states.add([
|
||||
new wp.media.controller.AudioDetails( {
|
||||
media: this.media
|
||||
} ),
|
||||
|
||||
new MediaLibrary( {
|
||||
type: 'audio',
|
||||
id: 'replace-audio',
|
||||
title: l10n.audioReplaceTitle,
|
||||
toolbar: 'replace-audio',
|
||||
media: this.media,
|
||||
menu: 'audio-details'
|
||||
} ),
|
||||
|
||||
new MediaLibrary( {
|
||||
type: 'audio',
|
||||
id: 'add-audio-source',
|
||||
title: l10n.audioAddSourceTitle,
|
||||
toolbar: 'add-audio-source',
|
||||
media: this.media,
|
||||
menu: false
|
||||
} )
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = AudioDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 7 */
|
||||
/***/ "./src/js/media/views/frame/video-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var MediaDetails = wp.media.view.MediaFrame.MediaDetails,
|
||||
@ -867,7 +912,8 @@ module.exports = VideoDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 8 */
|
||||
|
||||
/***/ "./src/js/media/views/media-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/* global MediaElementPlayer */
|
||||
@ -1041,51 +1087,8 @@ module.exports = MediaDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 9 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var MediaDetails = wp.media.view.MediaDetails,
|
||||
AudioDetails;
|
||||
|
||||
/**
|
||||
* wp.media.view.AudioDetails
|
||||
*
|
||||
* @memberOf wp.media.view
|
||||
*
|
||||
* @class
|
||||
* @augments wp.media.view.MediaDetails
|
||||
* @augments wp.media.view.Settings.AttachmentDisplay
|
||||
* @augments wp.media.view.Settings
|
||||
* @augments wp.media.View
|
||||
* @augments wp.Backbone.View
|
||||
* @augments Backbone.View
|
||||
*/
|
||||
AudioDetails = MediaDetails.extend(/** @lends wp.media.view.AudioDetails.prototype */{
|
||||
className: 'audio-details',
|
||||
template: wp.template('audio-details'),
|
||||
|
||||
setMedia: function() {
|
||||
var audio = this.$('.wp-audio-shortcode');
|
||||
|
||||
if ( audio.find( 'source' ).length ) {
|
||||
if ( audio.is(':hidden') ) {
|
||||
audio.show();
|
||||
}
|
||||
this.media = MediaDetails.prepareSrc( audio.get(0) );
|
||||
} else {
|
||||
audio.hide();
|
||||
this.media = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = AudioDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 10 */
|
||||
/***/ "./src/js/media/views/video-details.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var MediaDetails = wp.media.view.MediaDetails,
|
||||
@ -1133,5 +1136,14 @@ VideoDetails = MediaDetails.extend(/** @lends wp.media.view.VideoDetails.prototy
|
||||
module.exports = VideoDetails;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 0:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__("./src/js/_enqueues/wp/media/audiovideo.js");
|
||||
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
|
||||
/******/ });
|
2
wp-includes/js/media-audiovideo.min.js
vendored
2
wp-includes/js/media-audiovideo.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/media-grid.min.js
vendored
2
wp-includes/js/media-grid.min.js
vendored
File diff suppressed because one or more lines are too long
@ -81,20 +81,12 @@
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 22);
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 2);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ 22:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(23);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 23:
|
||||
/***/ "./src/js/_enqueues/wp/media/models.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
/**
|
||||
@ -167,12 +159,12 @@ l10n = media.model.l10n = window._wpMediaModelsL10n || {};
|
||||
media.model.settings = l10n.settings || {};
|
||||
delete l10n.settings;
|
||||
|
||||
Attachment = media.model.Attachment = __webpack_require__( 24 );
|
||||
Attachments = media.model.Attachments = __webpack_require__( 25 );
|
||||
Attachment = media.model.Attachment = __webpack_require__( "./src/js/media/models/attachment.js" );
|
||||
Attachments = media.model.Attachments = __webpack_require__( "./src/js/media/models/attachments.js" );
|
||||
|
||||
media.model.Query = __webpack_require__( 26 );
|
||||
media.model.PostImage = __webpack_require__( 27 );
|
||||
media.model.Selection = __webpack_require__( 28 );
|
||||
media.model.Query = __webpack_require__( "./src/js/media/models/query.js" );
|
||||
media.model.PostImage = __webpack_require__( "./src/js/media/models/post-image.js" );
|
||||
media.model.Selection = __webpack_require__( "./src/js/media/models/selection.js" );
|
||||
|
||||
/**
|
||||
* ========================================================================
|
||||
@ -345,7 +337,7 @@ $(window).on('unload', function(){
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 24:
|
||||
/***/ "./src/js/media/models/attachment.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var $ = Backbone.$,
|
||||
@ -521,7 +513,7 @@ module.exports = Attachment;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 25:
|
||||
/***/ "./src/js/media/models/attachments.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/**
|
||||
@ -1108,7 +1100,168 @@ module.exports = Attachments;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 26:
|
||||
/***/ "./src/js/media/models/post-image.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/**
|
||||
* wp.media.model.PostImage
|
||||
*
|
||||
* An instance of an image that's been embedded into a post.
|
||||
*
|
||||
* Used in the embedded image attachment display settings modal - @see wp.media.view.MediaFrame.ImageDetails.
|
||||
*
|
||||
* @memberOf wp.media.model
|
||||
*
|
||||
* @class
|
||||
* @augments Backbone.Model
|
||||
*
|
||||
* @param {int} [attributes] Initial model attributes.
|
||||
* @param {int} [attributes.attachment_id] ID of the attachment.
|
||||
**/
|
||||
var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.prototype */{
|
||||
|
||||
initialize: function( attributes ) {
|
||||
var Attachment = wp.media.model.Attachment;
|
||||
this.attachment = false;
|
||||
|
||||
if ( attributes.attachment_id ) {
|
||||
this.attachment = Attachment.get( attributes.attachment_id );
|
||||
if ( this.attachment.get( 'url' ) ) {
|
||||
this.dfd = jQuery.Deferred();
|
||||
this.dfd.resolve();
|
||||
} else {
|
||||
this.dfd = this.attachment.fetch();
|
||||
}
|
||||
this.bindAttachmentListeners();
|
||||
}
|
||||
|
||||
// Keep URL in sync with changes to the type of link.
|
||||
this.on( 'change:link', this.updateLinkUrl, this );
|
||||
this.on( 'change:size', this.updateSize, this );
|
||||
|
||||
this.setLinkTypeFromUrl();
|
||||
this.setAspectRatio();
|
||||
|
||||
this.set( 'originalUrl', attributes.url );
|
||||
},
|
||||
|
||||
bindAttachmentListeners: function() {
|
||||
this.listenTo( this.attachment, 'sync', this.setLinkTypeFromUrl );
|
||||
this.listenTo( this.attachment, 'sync', this.setAspectRatio );
|
||||
this.listenTo( this.attachment, 'change', this.updateSize );
|
||||
},
|
||||
|
||||
changeAttachment: function( attachment, props ) {
|
||||
this.stopListening( this.attachment );
|
||||
this.attachment = attachment;
|
||||
this.bindAttachmentListeners();
|
||||
|
||||
this.set( 'attachment_id', this.attachment.get( 'id' ) );
|
||||
this.set( 'caption', this.attachment.get( 'caption' ) );
|
||||
this.set( 'alt', this.attachment.get( 'alt' ) );
|
||||
this.set( 'size', props.get( 'size' ) );
|
||||
this.set( 'align', props.get( 'align' ) );
|
||||
this.set( 'link', props.get( 'link' ) );
|
||||
this.updateLinkUrl();
|
||||
this.updateSize();
|
||||
},
|
||||
|
||||
setLinkTypeFromUrl: function() {
|
||||
var linkUrl = this.get( 'linkUrl' ),
|
||||
type;
|
||||
|
||||
if ( ! linkUrl ) {
|
||||
this.set( 'link', 'none' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Default to custom if there is a linkUrl.
|
||||
type = 'custom';
|
||||
|
||||
if ( this.attachment ) {
|
||||
if ( this.attachment.get( 'url' ) === linkUrl ) {
|
||||
type = 'file';
|
||||
} else if ( this.attachment.get( 'link' ) === linkUrl ) {
|
||||
type = 'post';
|
||||
}
|
||||
} else {
|
||||
if ( this.get( 'url' ) === linkUrl ) {
|
||||
type = 'file';
|
||||
}
|
||||
}
|
||||
|
||||
this.set( 'link', type );
|
||||
},
|
||||
|
||||
updateLinkUrl: function() {
|
||||
var link = this.get( 'link' ),
|
||||
url;
|
||||
|
||||
switch( link ) {
|
||||
case 'file':
|
||||
if ( this.attachment ) {
|
||||
url = this.attachment.get( 'url' );
|
||||
} else {
|
||||
url = this.get( 'url' );
|
||||
}
|
||||
this.set( 'linkUrl', url );
|
||||
break;
|
||||
case 'post':
|
||||
this.set( 'linkUrl', this.attachment.get( 'link' ) );
|
||||
break;
|
||||
case 'none':
|
||||
this.set( 'linkUrl', '' );
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
updateSize: function() {
|
||||
var size;
|
||||
|
||||
if ( ! this.attachment ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.get( 'size' ) === 'custom' ) {
|
||||
this.set( 'width', this.get( 'customWidth' ) );
|
||||
this.set( 'height', this.get( 'customHeight' ) );
|
||||
this.set( 'url', this.get( 'originalUrl' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
size = this.attachment.get( 'sizes' )[ this.get( 'size' ) ];
|
||||
|
||||
if ( ! size ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set( 'url', size.url );
|
||||
this.set( 'width', size.width );
|
||||
this.set( 'height', size.height );
|
||||
},
|
||||
|
||||
setAspectRatio: function() {
|
||||
var full;
|
||||
|
||||
if ( this.attachment && this.attachment.get( 'sizes' ) ) {
|
||||
full = this.attachment.get( 'sizes' ).full;
|
||||
|
||||
if ( full ) {
|
||||
this.set( 'aspectRatio', full.width / full.height );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.set( 'aspectRatio', this.get( 'customWidth' ) / this.get( 'customHeight' ) );
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = PostImage;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/js/media/models/query.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var Attachments = wp.media.model.Attachments,
|
||||
@ -1421,168 +1574,7 @@ module.exports = Query;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 27:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
/**
|
||||
* wp.media.model.PostImage
|
||||
*
|
||||
* An instance of an image that's been embedded into a post.
|
||||
*
|
||||
* Used in the embedded image attachment display settings modal - @see wp.media.view.MediaFrame.ImageDetails.
|
||||
*
|
||||
* @memberOf wp.media.model
|
||||
*
|
||||
* @class
|
||||
* @augments Backbone.Model
|
||||
*
|
||||
* @param {int} [attributes] Initial model attributes.
|
||||
* @param {int} [attributes.attachment_id] ID of the attachment.
|
||||
**/
|
||||
var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.prototype */{
|
||||
|
||||
initialize: function( attributes ) {
|
||||
var Attachment = wp.media.model.Attachment;
|
||||
this.attachment = false;
|
||||
|
||||
if ( attributes.attachment_id ) {
|
||||
this.attachment = Attachment.get( attributes.attachment_id );
|
||||
if ( this.attachment.get( 'url' ) ) {
|
||||
this.dfd = jQuery.Deferred();
|
||||
this.dfd.resolve();
|
||||
} else {
|
||||
this.dfd = this.attachment.fetch();
|
||||
}
|
||||
this.bindAttachmentListeners();
|
||||
}
|
||||
|
||||
// Keep URL in sync with changes to the type of link.
|
||||
this.on( 'change:link', this.updateLinkUrl, this );
|
||||
this.on( 'change:size', this.updateSize, this );
|
||||
|
||||
this.setLinkTypeFromUrl();
|
||||
this.setAspectRatio();
|
||||
|
||||
this.set( 'originalUrl', attributes.url );
|
||||
},
|
||||
|
||||
bindAttachmentListeners: function() {
|
||||
this.listenTo( this.attachment, 'sync', this.setLinkTypeFromUrl );
|
||||
this.listenTo( this.attachment, 'sync', this.setAspectRatio );
|
||||
this.listenTo( this.attachment, 'change', this.updateSize );
|
||||
},
|
||||
|
||||
changeAttachment: function( attachment, props ) {
|
||||
this.stopListening( this.attachment );
|
||||
this.attachment = attachment;
|
||||
this.bindAttachmentListeners();
|
||||
|
||||
this.set( 'attachment_id', this.attachment.get( 'id' ) );
|
||||
this.set( 'caption', this.attachment.get( 'caption' ) );
|
||||
this.set( 'alt', this.attachment.get( 'alt' ) );
|
||||
this.set( 'size', props.get( 'size' ) );
|
||||
this.set( 'align', props.get( 'align' ) );
|
||||
this.set( 'link', props.get( 'link' ) );
|
||||
this.updateLinkUrl();
|
||||
this.updateSize();
|
||||
},
|
||||
|
||||
setLinkTypeFromUrl: function() {
|
||||
var linkUrl = this.get( 'linkUrl' ),
|
||||
type;
|
||||
|
||||
if ( ! linkUrl ) {
|
||||
this.set( 'link', 'none' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Default to custom if there is a linkUrl.
|
||||
type = 'custom';
|
||||
|
||||
if ( this.attachment ) {
|
||||
if ( this.attachment.get( 'url' ) === linkUrl ) {
|
||||
type = 'file';
|
||||
} else if ( this.attachment.get( 'link' ) === linkUrl ) {
|
||||
type = 'post';
|
||||
}
|
||||
} else {
|
||||
if ( this.get( 'url' ) === linkUrl ) {
|
||||
type = 'file';
|
||||
}
|
||||
}
|
||||
|
||||
this.set( 'link', type );
|
||||
},
|
||||
|
||||
updateLinkUrl: function() {
|
||||
var link = this.get( 'link' ),
|
||||
url;
|
||||
|
||||
switch( link ) {
|
||||
case 'file':
|
||||
if ( this.attachment ) {
|
||||
url = this.attachment.get( 'url' );
|
||||
} else {
|
||||
url = this.get( 'url' );
|
||||
}
|
||||
this.set( 'linkUrl', url );
|
||||
break;
|
||||
case 'post':
|
||||
this.set( 'linkUrl', this.attachment.get( 'link' ) );
|
||||
break;
|
||||
case 'none':
|
||||
this.set( 'linkUrl', '' );
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
updateSize: function() {
|
||||
var size;
|
||||
|
||||
if ( ! this.attachment ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.get( 'size' ) === 'custom' ) {
|
||||
this.set( 'width', this.get( 'customWidth' ) );
|
||||
this.set( 'height', this.get( 'customHeight' ) );
|
||||
this.set( 'url', this.get( 'originalUrl' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
size = this.attachment.get( 'sizes' )[ this.get( 'size' ) ];
|
||||
|
||||
if ( ! size ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set( 'url', size.url );
|
||||
this.set( 'width', size.width );
|
||||
this.set( 'height', size.height );
|
||||
},
|
||||
|
||||
setAspectRatio: function() {
|
||||
var full;
|
||||
|
||||
if ( this.attachment && this.attachment.get( 'sizes' ) ) {
|
||||
full = this.attachment.get( 'sizes' ).full;
|
||||
|
||||
if ( full ) {
|
||||
this.set( 'aspectRatio', full.width / full.height );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.set( 'aspectRatio', this.get( 'customWidth' ) / this.get( 'customHeight' ) );
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = PostImage;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 28:
|
||||
/***/ "./src/js/media/models/selection.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
var Attachments = wp.media.model.Attachments,
|
||||
@ -1684,6 +1676,14 @@ Selection = Attachments.extend(/** @lends wp.media.model.Selection.prototype */{
|
||||
module.exports = Selection;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2:
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__("./src/js/_enqueues/wp/media/models.js");
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
2
wp-includes/js/media-models.min.js
vendored
2
wp-includes/js/media-models.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
2
wp-includes/js/media-views.min.js
vendored
2
wp-includes/js/media-views.min.js
vendored
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-50983';
|
||||
$wp_version = '5.8-alpha-50984';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user