[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["mediaUtils"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = 485); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 0: 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = this["wp"]["element"]; }()); 94 95 /***/ }), 96 97 /***/ 1: 98 /***/ (function(module, exports) { 99 100 (function() { module.exports = this["wp"]["i18n"]; }()); 101 102 /***/ }), 103 104 /***/ 12: 105 /***/ (function(module, __webpack_exports__, __webpack_require__) { 106 107 "use strict"; 108 109 // EXPORTS 110 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; }); 111 112 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js 113 var arrayWithHoles = __webpack_require__(38); 114 115 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js 116 function _iterableToArrayLimit(arr, i) { 117 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 118 var _arr = []; 119 var _n = true; 120 var _d = false; 121 var _e = undefined; 122 123 try { 124 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 125 _arr.push(_s.value); 126 127 if (i && _arr.length === i) break; 128 } 129 } catch (err) { 130 _d = true; 131 _e = err; 132 } finally { 133 try { 134 if (!_n && _i["return"] != null) _i["return"](); 135 } finally { 136 if (_d) throw _e; 137 } 138 } 139 140 return _arr; 141 } 142 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js 143 var unsupportedIterableToArray = __webpack_require__(31); 144 145 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js 146 var nonIterableRest = __webpack_require__(39); 147 148 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js 149 150 151 152 153 function _slicedToArray(arr, i) { 154 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])(); 155 } 156 157 /***/ }), 158 159 /***/ 16: 160 /***/ (function(module, __webpack_exports__, __webpack_require__) { 161 162 "use strict"; 163 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; }); 164 function _assertThisInitialized(self) { 165 if (self === void 0) { 166 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 167 } 168 169 return self; 170 } 171 172 /***/ }), 173 174 /***/ 17: 175 /***/ (function(module, __webpack_exports__, __webpack_require__) { 176 177 "use strict"; 178 179 // EXPORTS 180 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); 181 182 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js 183 var arrayLikeToArray = __webpack_require__(27); 184 185 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js 186 187 function _arrayWithoutHoles(arr) { 188 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); 189 } 190 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js 191 var iterableToArray = __webpack_require__(37); 192 193 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js 194 var unsupportedIterableToArray = __webpack_require__(31); 195 196 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js 197 function _nonIterableSpread() { 198 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 199 } 200 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 201 202 203 204 205 function _toConsumableArray(arr) { 206 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); 207 } 208 209 /***/ }), 210 211 /***/ 19: 212 /***/ (function(module, __webpack_exports__, __webpack_require__) { 213 214 "use strict"; 215 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); 216 function _getPrototypeOf(o) { 217 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 218 return o.__proto__ || Object.getPrototypeOf(o); 219 }; 220 return _getPrototypeOf(o); 221 } 222 223 /***/ }), 224 225 /***/ 2: 226 /***/ (function(module, exports) { 227 228 (function() { module.exports = this["lodash"]; }()); 229 230 /***/ }), 231 232 /***/ 20: 233 /***/ (function(module, exports) { 234 235 (function() { module.exports = this["regeneratorRuntime"]; }()); 236 237 /***/ }), 238 239 /***/ 21: 240 /***/ (function(module, __webpack_exports__, __webpack_require__) { 241 242 "use strict"; 243 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); 244 function _classCallCheck(instance, Constructor) { 245 if (!(instance instanceof Constructor)) { 246 throw new TypeError("Cannot call a class as a function"); 247 } 248 } 249 250 /***/ }), 251 252 /***/ 22: 253 /***/ (function(module, __webpack_exports__, __webpack_require__) { 254 255 "use strict"; 256 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); 257 function _defineProperties(target, props) { 258 for (var i = 0; i < props.length; i++) { 259 var descriptor = props[i]; 260 descriptor.enumerable = descriptor.enumerable || false; 261 descriptor.configurable = true; 262 if ("value" in descriptor) descriptor.writable = true; 263 Object.defineProperty(target, descriptor.key, descriptor); 264 } 265 } 266 267 function _createClass(Constructor, protoProps, staticProps) { 268 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 269 if (staticProps) _defineProperties(Constructor, staticProps); 270 return Constructor; 271 } 272 273 /***/ }), 274 275 /***/ 23: 276 /***/ (function(module, __webpack_exports__, __webpack_require__) { 277 278 "use strict"; 279 280 // EXPORTS 281 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _inherits; }); 282 283 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js 284 function _setPrototypeOf(o, p) { 285 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 286 o.__proto__ = p; 287 return o; 288 }; 289 290 return _setPrototypeOf(o, p); 291 } 292 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js 293 294 function _inherits(subClass, superClass) { 295 if (typeof superClass !== "function" && superClass !== null) { 296 throw new TypeError("Super expression must either be null or a function"); 297 } 298 299 subClass.prototype = Object.create(superClass && superClass.prototype, { 300 constructor: { 301 value: subClass, 302 writable: true, 303 configurable: true 304 } 305 }); 306 if (superClass) _setPrototypeOf(subClass, superClass); 307 } 308 309 /***/ }), 310 311 /***/ 24: 312 /***/ (function(module, __webpack_exports__, __webpack_require__) { 313 314 "use strict"; 315 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); 316 /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40); 317 /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16); 318 319 320 function _possibleConstructorReturn(self, call) { 321 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { 322 return call; 323 } 324 325 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); 326 } 327 328 /***/ }), 329 330 /***/ 27: 331 /***/ (function(module, __webpack_exports__, __webpack_require__) { 332 333 "use strict"; 334 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); 335 function _arrayLikeToArray(arr, len) { 336 if (len == null || len > arr.length) len = arr.length; 337 338 for (var i = 0, arr2 = new Array(len); i < len; i++) { 339 arr2[i] = arr[i]; 340 } 341 342 return arr2; 343 } 344 345 /***/ }), 346 347 /***/ 31: 348 /***/ (function(module, __webpack_exports__, __webpack_require__) { 349 350 "use strict"; 351 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); 352 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27); 353 354 function _unsupportedIterableToArray(o, minLen) { 355 if (!o) return; 356 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 357 var n = Object.prototype.toString.call(o).slice(8, -1); 358 if (n === "Object" && o.constructor) n = o.constructor.name; 359 if (n === "Map" || n === "Set") return Array.from(o); 360 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); 361 } 362 363 /***/ }), 364 365 /***/ 37: 366 /***/ (function(module, __webpack_exports__, __webpack_require__) { 367 368 "use strict"; 369 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); 370 function _iterableToArray(iter) { 371 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 372 } 373 374 /***/ }), 375 376 /***/ 38: 377 /***/ (function(module, __webpack_exports__, __webpack_require__) { 378 379 "use strict"; 380 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); 381 function _arrayWithHoles(arr) { 382 if (Array.isArray(arr)) return arr; 383 } 384 385 /***/ }), 386 387 /***/ 39: 388 /***/ (function(module, __webpack_exports__, __webpack_require__) { 389 390 "use strict"; 391 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); 392 function _nonIterableRest() { 393 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 394 } 395 396 /***/ }), 397 398 /***/ 40: 399 /***/ (function(module, __webpack_exports__, __webpack_require__) { 400 401 "use strict"; 402 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); 403 function _typeof(obj) { 404 "@babel/helpers - typeof"; 405 406 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 407 _typeof = function _typeof(obj) { 408 return typeof obj; 409 }; 410 } else { 411 _typeof = function _typeof(obj) { 412 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 413 }; 414 } 415 416 return _typeof(obj); 417 } 418 419 /***/ }), 420 421 /***/ 41: 422 /***/ (function(module, exports) { 423 424 (function() { module.exports = this["wp"]["blob"]; }()); 425 426 /***/ }), 427 428 /***/ 45: 429 /***/ (function(module, __webpack_exports__, __webpack_require__) { 430 431 "use strict"; 432 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); 433 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 434 try { 435 var info = gen[key](arg); 436 var value = info.value; 437 } catch (error) { 438 reject(error); 439 return; 440 } 441 442 if (info.done) { 443 resolve(value); 444 } else { 445 Promise.resolve(value).then(_next, _throw); 446 } 447 } 448 449 function _asyncToGenerator(fn) { 450 return function () { 451 var self = this, 452 args = arguments; 453 return new Promise(function (resolve, reject) { 454 var gen = fn.apply(self, args); 455 456 function _next(value) { 457 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 458 } 459 460 function _throw(err) { 461 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 462 } 463 464 _next(undefined); 465 }); 466 }; 467 } 468 469 /***/ }), 470 471 /***/ 47: 472 /***/ (function(module, exports) { 473 474 (function() { module.exports = this["wp"]["apiFetch"]; }()); 475 476 /***/ }), 477 478 /***/ 485: 479 /***/ (function(module, __webpack_exports__, __webpack_require__) { 480 481 "use strict"; 482 // ESM COMPAT FLAG 483 __webpack_require__.r(__webpack_exports__); 484 485 // EXPORTS 486 __webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return /* reexport */ media_upload; }); 487 __webpack_require__.d(__webpack_exports__, "uploadMedia", function() { return /* reexport */ uploadMedia; }); 488 489 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js 490 var classCallCheck = __webpack_require__(21); 491 492 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js 493 var createClass = __webpack_require__(22); 494 495 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js 496 var assertThisInitialized = __webpack_require__(16); 497 498 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules 499 var inherits = __webpack_require__(23); 500 501 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js 502 var possibleConstructorReturn = __webpack_require__(24); 503 504 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js 505 var getPrototypeOf = __webpack_require__(19); 506 507 // EXTERNAL MODULE: external {"this":"lodash"} 508 var external_this_lodash_ = __webpack_require__(2); 509 510 // EXTERNAL MODULE: external {"this":["wp","element"]} 511 var external_this_wp_element_ = __webpack_require__(0); 512 513 // EXTERNAL MODULE: external {"this":["wp","i18n"]} 514 var external_this_wp_i18n_ = __webpack_require__(1); 515 516 // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/media-upload/index.js 517 518 519 520 521 522 523 524 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; } 525 526 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 527 528 /** 529 * External dependencies 530 */ 531 532 /** 533 * WordPress dependencies 534 */ 535 536 537 538 var _window = window, 539 wp = _window.wp; 540 var DEFAULT_EMPTY_GALLERY = []; 541 /** 542 * Prepares the Featured Image toolbars and frames. 543 * 544 * @return {wp.media.view.MediaFrame.Select} The default media workflow. 545 */ 546 547 var getFeaturedImageMediaFrame = function getFeaturedImageMediaFrame() { 548 return wp.media.view.MediaFrame.Select.extend({ 549 /** 550 * Enables the Set Featured Image Button. 551 * 552 * @param {Object} toolbar toolbar for featured image state 553 * @return {void} 554 */ 555 featuredImageToolbar: function featuredImageToolbar(toolbar) { 556 this.createSelectToolbar(toolbar, { 557 text: wp.media.view.l10n.setFeaturedImage, 558 state: this.options.state 559 }); 560 }, 561 562 /** 563 * Handle the edit state requirements of selected media item. 564 * 565 * @return {void} 566 */ 567 editState: function editState() { 568 var selection = this.state('featured-image').get('selection'); 569 var view = new wp.media.view.EditImage({ 570 model: selection.single(), 571 controller: this 572 }).render(); // Set the view to the EditImage frame using the selected image. 573 574 this.content.set(view); // After bringing in the frame, load the actual editor via an ajax call. 575 576 view.loadEditor(); 577 }, 578 579 /** 580 * Create the default states. 581 * 582 * @return {void} 583 */ 584 createStates: function createStates() { 585 this.on('toolbar:create:featured-image', this.featuredImageToolbar, this); 586 this.on('content:render:edit-image', this.editState, this); 587 this.states.add([new wp.media.controller.FeaturedImage(), new wp.media.controller.EditImage({ 588 model: this.options.editImage 589 })]); 590 } 591 }); 592 }; 593 /** 594 * Prepares the Gallery toolbars and frames. 595 * 596 * @return {wp.media.view.MediaFrame.Post} The default media workflow. 597 */ 598 599 600 var media_upload_getGalleryDetailsMediaFrame = function getGalleryDetailsMediaFrame() { 601 /** 602 * Custom gallery details frame. 603 * 604 * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js 605 * @class GalleryDetailsMediaFrame 606 * @class 607 */ 608 return wp.media.view.MediaFrame.Post.extend({ 609 /** 610 * Set up gallery toolbar. 611 * 612 * @return {void} 613 */ 614 galleryToolbar: function galleryToolbar() { 615 var editing = this.state().get('editing'); 616 this.toolbar.set(new wp.media.view.Toolbar({ 617 controller: this, 618 items: { 619 insert: { 620 style: 'primary', 621 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery, 622 priority: 80, 623 requires: { 624 library: true 625 }, 626 627 /** 628 * @fires wp.media.controller.State#update 629 */ 630 click: function click() { 631 var controller = this.controller, 632 state = controller.state(); 633 controller.close(); 634 state.trigger('update', state.get('library')); // Restore and reset the default state. 635 636 controller.setState(controller.options.state); 637 controller.reset(); 638 } 639 } 640 } 641 })); 642 }, 643 644 /** 645 * Handle the edit state requirements of selected media item. 646 * 647 * @return {void} 648 */ 649 editState: function editState() { 650 var selection = this.state('gallery').get('selection'); 651 var view = new wp.media.view.EditImage({ 652 model: selection.single(), 653 controller: this 654 }).render(); // Set the view to the EditImage frame using the selected image. 655 656 this.content.set(view); // After bringing in the frame, load the actual editor via an ajax call. 657 658 view.loadEditor(); 659 }, 660 661 /** 662 * Create the default states. 663 * 664 * @return {void} 665 */ 666 createStates: function createStates() { 667 this.on('toolbar:create:main-gallery', this.galleryToolbar, this); 668 this.on('content:render:edit-image', this.editState, this); 669 this.states.add([new wp.media.controller.Library({ 670 id: 'gallery', 671 title: wp.media.view.l10n.createGalleryTitle, 672 priority: 40, 673 toolbar: 'main-gallery', 674 filterable: 'uploaded', 675 multiple: 'add', 676 editable: false, 677 library: wp.media.query(Object(external_this_lodash_["defaults"])({ 678 type: 'image' 679 }, this.options.library)) 680 }), new wp.media.controller.EditImage({ 681 model: this.options.editImage 682 }), new wp.media.controller.GalleryEdit({ 683 library: this.options.selection, 684 editing: this.options.editing, 685 menu: 'gallery', 686 displaySettings: false, 687 multiple: true 688 }), new wp.media.controller.GalleryAdd()]); 689 } 690 }); 691 }; // the media library image object contains numerous attributes 692 // we only need this set to display the image in the library 693 694 695 var media_upload_slimImageObject = function slimImageObject(img) { 696 var attrSet = ['sizes', 'mime', 'type', 'subtype', 'id', 'url', 'alt', 'link', 'caption']; 697 return Object(external_this_lodash_["pick"])(img, attrSet); 698 }; 699 700 var getAttachmentsCollection = function getAttachmentsCollection(ids) { 701 return wp.media.query({ 702 order: 'ASC', 703 orderby: 'post__in', 704 post__in: ids, 705 posts_per_page: -1, 706 query: true, 707 type: 'image' 708 }); 709 }; 710 711 var media_upload_MediaUpload = /*#__PURE__*/function (_Component) { 712 Object(inherits["a" /* default */])(MediaUpload, _Component); 713 714 var _super = _createSuper(MediaUpload); 715 716 function MediaUpload(_ref) { 717 var _this; 718 719 var allowedTypes = _ref.allowedTypes, 720 _ref$gallery = _ref.gallery, 721 gallery = _ref$gallery === void 0 ? false : _ref$gallery, 722 _ref$unstableFeatured = _ref.unstableFeaturedImageFlow, 723 unstableFeaturedImageFlow = _ref$unstableFeatured === void 0 ? false : _ref$unstableFeatured, 724 modalClass = _ref.modalClass, 725 _ref$multiple = _ref.multiple, 726 multiple = _ref$multiple === void 0 ? false : _ref$multiple, 727 _ref$title = _ref.title, 728 title = _ref$title === void 0 ? Object(external_this_wp_i18n_["__"])('Select or Upload Media') : _ref$title; 729 730 Object(classCallCheck["a" /* default */])(this, MediaUpload); 731 732 _this = _super.apply(this, arguments); 733 _this.openModal = _this.openModal.bind(Object(assertThisInitialized["a" /* default */])(_this)); 734 _this.onOpen = _this.onOpen.bind(Object(assertThisInitialized["a" /* default */])(_this)); 735 _this.onSelect = _this.onSelect.bind(Object(assertThisInitialized["a" /* default */])(_this)); 736 _this.onUpdate = _this.onUpdate.bind(Object(assertThisInitialized["a" /* default */])(_this)); 737 _this.onClose = _this.onClose.bind(Object(assertThisInitialized["a" /* default */])(_this)); 738 739 if (gallery) { 740 _this.buildAndSetGalleryFrame(); 741 } else { 742 var frameConfig = { 743 title: title, 744 multiple: multiple 745 }; 746 747 if (!!allowedTypes) { 748 frameConfig.library = { 749 type: allowedTypes 750 }; 751 } 752 753 _this.frame = wp.media(frameConfig); 754 } 755 756 if (modalClass) { 757 _this.frame.$el.addClass(modalClass); 758 } 759 760 if (unstableFeaturedImageFlow) { 761 _this.buildAndSetFeatureImageFrame(); 762 } 763 764 _this.initializeListeners(); 765 766 return _this; 767 } 768 769 Object(createClass["a" /* default */])(MediaUpload, [{ 770 key: "initializeListeners", 771 value: function initializeListeners() { 772 // When an image is selected in the media frame... 773 this.frame.on('select', this.onSelect); 774 this.frame.on('update', this.onUpdate); 775 this.frame.on('open', this.onOpen); 776 this.frame.on('close', this.onClose); 777 } 778 /** 779 * Sets the Gallery frame and initializes listeners. 780 * 781 * @return {void} 782 */ 783 784 }, { 785 key: "buildAndSetGalleryFrame", 786 value: function buildAndSetGalleryFrame() { 787 var _this$props = this.props, 788 _this$props$addToGall = _this$props.addToGallery, 789 addToGallery = _this$props$addToGall === void 0 ? false : _this$props$addToGall, 790 allowedTypes = _this$props.allowedTypes, 791 _this$props$multiple = _this$props.multiple, 792 multiple = _this$props$multiple === void 0 ? false : _this$props$multiple, 793 _this$props$value = _this$props.value, 794 value = _this$props$value === void 0 ? DEFAULT_EMPTY_GALLERY : _this$props$value; // If the value did not changed there is no need to rebuild the frame, 795 // we can continue to use the existing one. 796 797 if (value === this.lastGalleryValue) { 798 return; 799 } 800 801 this.lastGalleryValue = value; // If a frame already existed remove it. 802 803 if (this.frame) { 804 this.frame.remove(); 805 } 806 807 var currentState; 808 809 if (addToGallery) { 810 currentState = 'gallery-library'; 811 } else { 812 currentState = value && value.length ? 'gallery-edit' : 'gallery'; 813 } 814 815 if (!this.GalleryDetailsMediaFrame) { 816 this.GalleryDetailsMediaFrame = media_upload_getGalleryDetailsMediaFrame(); 817 } 818 819 var attachments = getAttachmentsCollection(value); 820 var selection = new wp.media.model.Selection(attachments.models, { 821 props: attachments.props.toJSON(), 822 multiple: multiple 823 }); 824 this.frame = new this.GalleryDetailsMediaFrame({ 825 mimeType: allowedTypes, 826 state: currentState, 827 multiple: multiple, 828 selection: selection, 829 editing: value && value.length ? true : false 830 }); 831 wp.media.frame = this.frame; 832 this.initializeListeners(); 833 } 834 /** 835 * Initializes the Media Library requirements for the featured image flow. 836 * 837 * @return {void} 838 */ 839 840 }, { 841 key: "buildAndSetFeatureImageFrame", 842 value: function buildAndSetFeatureImageFrame() { 843 var featuredImageFrame = getFeaturedImageMediaFrame(); 844 var attachments = getAttachmentsCollection(this.props.value); 845 var selection = new wp.media.model.Selection(attachments.models, { 846 props: attachments.props.toJSON() 847 }); 848 this.frame = new featuredImageFrame({ 849 mimeType: this.props.allowedTypes, 850 state: 'featured-image', 851 multiple: this.props.multiple, 852 selection: selection, 853 editing: this.props.value ? true : false 854 }); 855 wp.media.frame = this.frame; 856 } 857 }, { 858 key: "componentWillUnmount", 859 value: function componentWillUnmount() { 860 this.frame.remove(); 861 } 862 }, { 863 key: "onUpdate", 864 value: function onUpdate(selections) { 865 var _this$props2 = this.props, 866 onSelect = _this$props2.onSelect, 867 _this$props2$multiple = _this$props2.multiple, 868 multiple = _this$props2$multiple === void 0 ? false : _this$props2$multiple; 869 var state = this.frame.state(); 870 var selectedImages = selections || state.get('selection'); 871 872 if (!selectedImages || !selectedImages.models.length) { 873 return; 874 } 875 876 if (multiple) { 877 onSelect(selectedImages.models.map(function (model) { 878 return media_upload_slimImageObject(model.toJSON()); 879 })); 880 } else { 881 onSelect(media_upload_slimImageObject(selectedImages.models[0].toJSON())); 882 } 883 } 884 }, { 885 key: "onSelect", 886 value: function onSelect() { 887 var _this$props3 = this.props, 888 onSelect = _this$props3.onSelect, 889 _this$props3$multiple = _this$props3.multiple, 890 multiple = _this$props3$multiple === void 0 ? false : _this$props3$multiple; // Get media attachment details from the frame state 891 892 var attachment = this.frame.state().get('selection').toJSON(); 893 onSelect(multiple ? attachment : attachment[0]); 894 } 895 }, { 896 key: "onOpen", 897 value: function onOpen() { 898 this.updateCollection(); 899 900 if (!this.props.value) { 901 return; 902 } 903 904 if (!this.props.gallery) { 905 var selection = this.frame.state().get('selection'); 906 Object(external_this_lodash_["castArray"])(this.props.value).forEach(function (id) { 907 selection.add(wp.media.attachment(id)); 908 }); 909 } // load the images so they are available in the media modal. 910 911 912 getAttachmentsCollection(Object(external_this_lodash_["castArray"])(this.props.value)).more(); 913 } 914 }, { 915 key: "onClose", 916 value: function onClose() { 917 var onClose = this.props.onClose; 918 919 if (onClose) { 920 onClose(); 921 } 922 } 923 }, { 924 key: "updateCollection", 925 value: function updateCollection() { 926 var frameContent = this.frame.content.get(); 927 928 if (frameContent && frameContent.collection) { 929 var collection = frameContent.collection; // clean all attachments we have in memory. 930 931 collection.toArray().forEach(function (model) { 932 return model.trigger('destroy', model); 933 }); // reset has more flag, if library had small amount of items all items may have been loaded before. 934 935 collection.mirroring._hasMore = true; // request items 936 937 collection.more(); 938 } 939 } 940 }, { 941 key: "openModal", 942 value: function openModal() { 943 if (this.props.gallery) { 944 this.buildAndSetGalleryFrame(); 945 } 946 947 this.frame.open(); 948 } 949 }, { 950 key: "render", 951 value: function render() { 952 return this.props.render({ 953 open: this.openModal 954 }); 955 } 956 }]); 957 958 return MediaUpload; 959 }(external_this_wp_element_["Component"]); 960 961 /* harmony default export */ var media_upload = (media_upload_MediaUpload); 962 963 // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js 964 965 966 // EXTERNAL MODULE: external {"this":"regeneratorRuntime"} 967 var external_this_regeneratorRuntime_ = __webpack_require__(20); 968 var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_); 969 970 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 971 var defineProperty = __webpack_require__(5); 972 973 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js 974 var asyncToGenerator = __webpack_require__(45); 975 976 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules 977 var toConsumableArray = __webpack_require__(17); 978 979 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules 980 var slicedToArray = __webpack_require__(12); 981 982 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} 983 var external_this_wp_apiFetch_ = __webpack_require__(47); 984 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); 985 986 // EXTERNAL MODULE: external {"this":["wp","blob"]} 987 var external_this_wp_blob_ = __webpack_require__(41); 988 989 // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/upload-media.js 990 991 992 993 994 995 996 997 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 998 999 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 1000 1001 function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } 1002 1003 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 1004 1005 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 1006 1007 /** 1008 * External dependencies 1009 */ 1010 1011 /** 1012 * WordPress dependencies 1013 */ 1014 1015 1016 1017 1018 /** 1019 * Browsers may use unexpected mime types, and they differ from browser to browser. 1020 * This function computes a flexible array of mime types from the mime type structured provided by the server. 1021 * Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ] 1022 * The computation of this array instead of directly using the object, 1023 * solves the problem in chrome where mp3 files have audio/mp3 as mime type instead of audio/mpeg. 1024 * https://bugs.chromium.org/p/chromium/issues/detail?id=227004 1025 * 1026 * @param {?Object} wpMimeTypesObject Mime type object received from the server. 1027 * Extensions are keys separated by '|' and values are mime types associated with an extension. 1028 * 1029 * @return {?Array} An array of mime types or the parameter passed if it was "falsy". 1030 */ 1031 1032 function getMimeTypesArray(wpMimeTypesObject) { 1033 if (!wpMimeTypesObject) { 1034 return wpMimeTypesObject; 1035 } 1036 1037 return Object(external_this_lodash_["flatMap"])(wpMimeTypesObject, function (mime, extensionsString) { 1038 var _mime$split = mime.split('/'), 1039 _mime$split2 = Object(slicedToArray["a" /* default */])(_mime$split, 1), 1040 type = _mime$split2[0]; 1041 1042 var extensions = extensionsString.split('|'); 1043 return [mime].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["map"])(extensions, function (extension) { 1044 return "".concat(type, "/").concat(extension); 1045 }))); 1046 }); 1047 } 1048 /** 1049 * Media Upload is used by audio, image, gallery, video, and file blocks to 1050 * handle uploading a media file when a file upload button is activated. 1051 * 1052 * TODO: future enhancement to add an upload indicator. 1053 * 1054 * @param {Object} $0 Parameters object passed to the function. 1055 * @param {?Array} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed. 1056 * @param {?Object} $0.additionalData Additional data to include in the request. 1057 * @param {Array} $0.filesList List of files. 1058 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site. 1059 * @param {Function} $0.onError Function called when an error happens. 1060 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available. 1061 * @param {?Object} $0.wpAllowedMimeTypes List of allowed mime types and file extensions. 1062 */ 1063 1064 function uploadMedia(_x) { 1065 return _uploadMedia.apply(this, arguments); 1066 } 1067 /** 1068 * @param {File} file Media File to Save. 1069 * @param {?Object} additionalData Additional data to include in the request. 1070 * 1071 * @return {Promise} Media Object Promise. 1072 */ 1073 1074 function _uploadMedia() { 1075 _uploadMedia = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(_ref) { 1076 var allowedTypes, _ref$additionalData, additionalData, filesList, maxUploadFileSize, _ref$onError, onError, onFileChange, _ref$wpAllowedMimeTyp, wpAllowedMimeTypes, files, filesSet, setAndUpdateFiles, isAllowedType, allowedMimeTypesForUser, isAllowedMimeTypeForUser, triggerError, validFiles, _iterator, _step, _mediaFile, idx, mediaFile, savedMedia, mediaObject, message; 1077 1078 return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) { 1079 while (1) { 1080 switch (_context.prev = _context.next) { 1081 case 0: 1082 allowedTypes = _ref.allowedTypes, _ref$additionalData = _ref.additionalData, additionalData = _ref$additionalData === void 0 ? {} : _ref$additionalData, filesList = _ref.filesList, maxUploadFileSize = _ref.maxUploadFileSize, _ref$onError = _ref.onError, onError = _ref$onError === void 0 ? external_this_lodash_["noop"] : _ref$onError, onFileChange = _ref.onFileChange, _ref$wpAllowedMimeTyp = _ref.wpAllowedMimeTypes, wpAllowedMimeTypes = _ref$wpAllowedMimeTyp === void 0 ? null : _ref$wpAllowedMimeTyp; 1083 // Cast filesList to array 1084 files = Object(toConsumableArray["a" /* default */])(filesList); 1085 filesSet = []; 1086 1087 setAndUpdateFiles = function setAndUpdateFiles(idx, value) { 1088 Object(external_this_wp_blob_["revokeBlobURL"])(Object(external_this_lodash_["get"])(filesSet, [idx, 'url'])); 1089 filesSet[idx] = value; 1090 onFileChange(Object(external_this_lodash_["compact"])(filesSet)); 1091 }; // Allowed type specified by consumer 1092 1093 1094 isAllowedType = function isAllowedType(fileType) { 1095 if (!allowedTypes) { 1096 return true; 1097 } 1098 1099 return Object(external_this_lodash_["some"])(allowedTypes, function (allowedType) { 1100 // If a complete mimetype is specified verify if it matches exactly the mime type of the file. 1101 if (Object(external_this_lodash_["includes"])(allowedType, '/')) { 1102 return allowedType === fileType; 1103 } // Otherwise a general mime type is used and we should verify if the file mimetype starts with it. 1104 1105 1106 return Object(external_this_lodash_["startsWith"])(fileType, "".concat(allowedType, "/")); 1107 }); 1108 }; // Allowed types for the current WP_User 1109 1110 1111 allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes); 1112 1113 isAllowedMimeTypeForUser = function isAllowedMimeTypeForUser(fileType) { 1114 return Object(external_this_lodash_["includes"])(allowedMimeTypesForUser, fileType); 1115 }; // Build the error message including the filename 1116 1117 1118 triggerError = function triggerError(error) { 1119 error.message = [Object(external_this_wp_element_["createElement"])("strong", { 1120 key: "filename" 1121 }, error.file.name), ': ', error.message]; 1122 onError(error); 1123 }; 1124 1125 validFiles = []; 1126 _iterator = _createForOfIteratorHelper(files); 1127 _context.prev = 10; 1128 1129 _iterator.s(); 1130 1131 case 12: 1132 if ((_step = _iterator.n()).done) { 1133 _context.next = 31; 1134 break; 1135 } 1136 1137 _mediaFile = _step.value; 1138 1139 if (!(allowedMimeTypesForUser && _mediaFile.type && !isAllowedMimeTypeForUser(_mediaFile.type))) { 1140 _context.next = 17; 1141 break; 1142 } 1143 1144 triggerError({ 1145 code: 'MIME_TYPE_NOT_ALLOWED_FOR_USER', 1146 message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not permitted for security reasons.'), 1147 file: _mediaFile 1148 }); 1149 return _context.abrupt("continue", 29); 1150 1151 case 17: 1152 if (!(_mediaFile.type && !isAllowedType(_mediaFile.type))) { 1153 _context.next = 20; 1154 break; 1155 } 1156 1157 triggerError({ 1158 code: 'MIME_TYPE_NOT_SUPPORTED', 1159 message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not supported here.'), 1160 file: _mediaFile 1161 }); 1162 return _context.abrupt("continue", 29); 1163 1164 case 20: 1165 if (!(maxUploadFileSize && _mediaFile.size > maxUploadFileSize)) { 1166 _context.next = 23; 1167 break; 1168 } 1169 1170 triggerError({ 1171 code: 'SIZE_ABOVE_LIMIT', 1172 message: Object(external_this_wp_i18n_["__"])('This file exceeds the maximum upload size for this site.'), 1173 file: _mediaFile 1174 }); 1175 return _context.abrupt("continue", 29); 1176 1177 case 23: 1178 if (!(_mediaFile.size <= 0)) { 1179 _context.next = 26; 1180 break; 1181 } 1182 1183 triggerError({ 1184 code: 'EMPTY_FILE', 1185 message: Object(external_this_wp_i18n_["__"])('This file is empty.'), 1186 file: _mediaFile 1187 }); 1188 return _context.abrupt("continue", 29); 1189 1190 case 26: 1191 validFiles.push(_mediaFile); // Set temporary URL to create placeholder media file, this is replaced 1192 // with final file from media gallery when upload is `done` below 1193 1194 filesSet.push({ 1195 url: Object(external_this_wp_blob_["createBlobURL"])(_mediaFile) 1196 }); 1197 onFileChange(filesSet); 1198 1199 case 29: 1200 _context.next = 12; 1201 break; 1202 1203 case 31: 1204 _context.next = 36; 1205 break; 1206 1207 case 33: 1208 _context.prev = 33; 1209 _context.t0 = _context["catch"](10); 1210 1211 _iterator.e(_context.t0); 1212 1213 case 36: 1214 _context.prev = 36; 1215 1216 _iterator.f(); 1217 1218 return _context.finish(36); 1219 1220 case 39: 1221 idx = 0; 1222 1223 case 40: 1224 if (!(idx < validFiles.length)) { 1225 _context.next = 59; 1226 break; 1227 } 1228 1229 mediaFile = validFiles[idx]; 1230 _context.prev = 42; 1231 _context.next = 45; 1232 return createMediaFromFile(mediaFile, additionalData); 1233 1234 case 45: 1235 savedMedia = _context.sent; 1236 mediaObject = _objectSpread(_objectSpread({}, Object(external_this_lodash_["omit"])(savedMedia, ['alt_text', 'source_url'])), {}, { 1237 alt: savedMedia.alt_text, 1238 caption: Object(external_this_lodash_["get"])(savedMedia, ['caption', 'raw'], ''), 1239 title: savedMedia.title.raw, 1240 url: savedMedia.source_url 1241 }); 1242 setAndUpdateFiles(idx, mediaObject); 1243 _context.next = 56; 1244 break; 1245 1246 case 50: 1247 _context.prev = 50; 1248 _context.t1 = _context["catch"](42); 1249 // Reset to empty on failure. 1250 setAndUpdateFiles(idx, null); 1251 message = void 0; 1252 1253 if (Object(external_this_lodash_["has"])(_context.t1, ['message'])) { 1254 message = Object(external_this_lodash_["get"])(_context.t1, ['message']); 1255 } else { 1256 message = Object(external_this_wp_i18n_["sprintf"])( // translators: %s: file name 1257 Object(external_this_wp_i18n_["__"])('Error while uploading file %s to the media library.'), mediaFile.name); 1258 } 1259 1260 onError({ 1261 code: 'GENERAL', 1262 message: message, 1263 file: mediaFile 1264 }); 1265 1266 case 56: 1267 ++idx; 1268 _context.next = 40; 1269 break; 1270 1271 case 59: 1272 case "end": 1273 return _context.stop(); 1274 } 1275 } 1276 }, _callee, null, [[10, 33, 36, 39], [42, 50]]); 1277 })); 1278 return _uploadMedia.apply(this, arguments); 1279 } 1280 1281 function createMediaFromFile(file, additionalData) { 1282 // Create upload payload 1283 var data = new window.FormData(); 1284 data.append('file', file, file.name || file.type.replace('/', '.')); 1285 Object(external_this_lodash_["forEach"])(additionalData, function (value, key) { 1286 return data.append(key, value); 1287 }); 1288 return external_this_wp_apiFetch_default()({ 1289 path: '/wp/v2/media', 1290 body: data, 1291 method: 'POST' 1292 }); 1293 } 1294 1295 // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/index.js 1296 1297 1298 // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/index.js 1299 1300 1301 1302 1303 /***/ }), 1304 1305 /***/ 5: 1306 /***/ (function(module, __webpack_exports__, __webpack_require__) { 1307 1308 "use strict"; 1309 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); 1310 function _defineProperty(obj, key, value) { 1311 if (key in obj) { 1312 Object.defineProperty(obj, key, { 1313 value: value, 1314 enumerable: true, 1315 configurable: true, 1316 writable: true 1317 }); 1318 } else { 1319 obj[key] = value; 1320 } 1321 1322 return obj; 1323 } 1324 1325 /***/ }) 1326 1327 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Jan 26 01:00:03 2021 | Cross-referenced by PHPXref 0.7.1 |