diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:57:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:57:26 +0000 |
commit | 30883c26bdceb9eaf32c8d4a1b0c1bce223b5226 (patch) | |
tree | 39a02e2aeb21ab5b7923c6f5757d66d55b708912 /wp-includes/js/dist/media-utils.js | |
parent | Adding upstream version 6.4.3+dfsg1. (diff) | |
download | wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.tar.xz wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.zip |
Adding upstream version 6.5+dfsg1.upstream/6.5+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/media-utils.js')
-rw-r--r-- | wp-includes/js/dist/media-utils.js | 131 |
1 files changed, 71 insertions, 60 deletions
diff --git a/wp-includes/js/dist/media-utils.js b/wp-includes/js/dist/media-utils.js index 7272265..f1db32a 100644 --- a/wp-includes/js/dist/media-utils.js +++ b/wp-includes/js/dist/media-utils.js @@ -1,48 +1,48 @@ -/******/ (function() { // webpackBootstrap +/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ // The require scope /******/ var __webpack_require__ = {}; /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ -/******/ !function() { +/******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { +/******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? -/******/ function() { return module['default']; } : -/******/ function() { return module; }; +/******/ () => (module['default']) : +/******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; -/******/ }(); +/******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ -/******/ !function() { +/******/ (() => { /******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = function(exports, definition) { +/******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; -/******/ }(); +/******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ !function() { -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } -/******/ }(); +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ -/******/ !function() { +/******/ (() => { /******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { +/******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; -/******/ }(); +/******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; @@ -51,14 +51,14 @@ __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { - MediaUpload: function() { return /* reexport */ media_upload; }, - uploadMedia: function() { return /* reexport */ uploadMedia; } + MediaUpload: () => (/* reexport */ media_upload), + uploadMedia: () => (/* reexport */ uploadMedia) }); ;// CONCATENATED MODULE: external ["wp","element"] -var external_wp_element_namespaceObject = window["wp"]["element"]; +const external_wp_element_namespaceObject = window["wp"]["element"]; ;// CONCATENATED MODULE: external ["wp","i18n"] -var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; +const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/media-upload/index.js /** * WordPress dependencies @@ -249,44 +249,13 @@ const getAttachmentsCollection = ids => { }); }; class MediaUpload extends external_wp_element_namespaceObject.Component { - constructor({ - allowedTypes, - gallery = false, - unstableFeaturedImageFlow = false, - modalClass, - multiple = false, - title = (0,external_wp_i18n_namespaceObject.__)('Select or Upload Media') - }) { + constructor() { super(...arguments); this.openModal = this.openModal.bind(this); this.onOpen = this.onOpen.bind(this); this.onSelect = this.onSelect.bind(this); this.onUpdate = this.onUpdate.bind(this); this.onClose = this.onClose.bind(this); - const { - wp - } = window; - if (gallery) { - this.buildAndSetGalleryFrame(); - } else { - const frameConfig = { - title, - multiple - }; - if (!!allowedTypes) { - frameConfig.library = { - type: allowedTypes - }; - } - this.frame = wp.media(frameConfig); - } - if (modalClass) { - this.frame.$el.addClass(modalClass); - } - if (unstableFeaturedImageFlow) { - this.buildAndSetFeatureImageFrame(); - } - this.initializeListeners(); } initializeListeners() { // When an image is selected in the media frame... @@ -357,22 +326,35 @@ class MediaUpload extends external_wp_element_namespaceObject.Component { const { wp } = window; + const { + value: featuredImageId, + multiple, + allowedTypes + } = this.props; const featuredImageFrame = getFeaturedImageMediaFrame(); - const attachments = getAttachmentsCollection(this.props.value); + const attachments = getAttachmentsCollection(featuredImageId); const selection = new wp.media.model.Selection(attachments.models, { props: attachments.props.toJSON() }); this.frame = new featuredImageFrame({ - mimeType: this.props.allowedTypes, + mimeType: allowedTypes, state: 'featured-image', - multiple: this.props.multiple, + multiple, selection, - editing: this.props.value ? true : false + editing: featuredImageId }); wp.media.frame = this.frame; + // In order to select the current featured image when opening + // the media library we have to set the appropriate settings. + // Currently they are set in php for the post editor, but + // not for site editor. + wp.media.view.settings.post = { + ...wp.media.view.settings.post, + featuredImageId: featuredImageId || -1 + }; } componentWillUnmount() { - this.frame.remove(); + this.frame?.remove(); } onUpdate(selections) { const { @@ -462,9 +444,38 @@ class MediaUpload extends external_wp_element_namespaceObject.Component { } } openModal() { - if (this.props.gallery) { + const { + allowedTypes, + gallery = false, + unstableFeaturedImageFlow = false, + modalClass, + multiple = false, + title = (0,external_wp_i18n_namespaceObject.__)('Select or Upload Media') + } = this.props; + const { + wp + } = window; + if (gallery) { this.buildAndSetGalleryFrame(); + } else { + const frameConfig = { + title, + multiple + }; + if (!!allowedTypes) { + frameConfig.library = { + type: allowedTypes + }; + } + this.frame = wp.media(frameConfig); } + if (modalClass) { + this.frame.$el.addClass(modalClass); + } + if (unstableFeaturedImageFlow) { + this.buildAndSetFeatureImageFrame(); + } + this.initializeListeners(); this.frame.open(); } render() { @@ -473,16 +484,16 @@ class MediaUpload extends external_wp_element_namespaceObject.Component { }); } } -/* harmony default export */ var media_upload = (MediaUpload); +/* harmony default export */ const media_upload = (MediaUpload); ;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js ;// CONCATENATED MODULE: external ["wp","apiFetch"] -var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; +const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); ;// CONCATENATED MODULE: external ["wp","blob"] -var external_wp_blob_namespaceObject = window["wp"]["blob"]; +const external_wp_blob_namespaceObject = window["wp"]["blob"]; ;// CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/upload-media.js /** * WordPress dependencies |