diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js index 480ccd918..c2d10ed03 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js @@ -1 +1 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t,r){var n=r(5);e.exports=function(e){for(var t=1;t {\n return (\n <>\n props.setOverwrite( value ) }\n />\n \n );\n};\n\n// Setup our properties.\nFeaturedTransformationsToggle = withSelect( ( select, ownProps ) => ( {\n media: ownProps.value ? select( 'core' ).getMedia( ownProps.value ) : {},\n overwrite_featured_transformations: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ '_overwrite_featured_transformations' ] ?? false,\n} ) )( FeaturedTransformationsToggle );\n\n// Setup our update method.\nFeaturedTransformationsToggle = withDispatch(\n ( dispatch ) => {\n return {\n setOverwrite: ( value ) => {\n dispatch( 'core/editor' ).editPost( { meta: { _overwrite_featured_transformations: value } } );\n }\n };\n }\n)( FeaturedTransformationsToggle );\n\n// Hook in and add our component.\nconst cldFilterFeatured = ( BlockEdit ) => {\n return ( props ) => {\n console.log( props );\n return (\n <>\n \n { props.value &&\n \n }\n \n );\n };\n};\n\n// Setup an init wrapper.\nconst Featured = {\n _init: function() {\n // Add it to Media Upload to allow for deeper connection with getting the media object, to determine if an asset has transformations.\n // Also adds deeper support for other image types within Guttenberg.\n // @todo: find other locations (i.e Video poster) where this may be needed.\n wp.hooks.addFilter( 'editor.MediaUpload', 'cloudinary/filter-featured-image', cldFilterFeatured );\n },\n};\n\n// Push Init.\nFeatured._init();\n\n// Export to keep it in scope.\nexport default Featured;\n","/* global window wp */\n\nimport { __ } from '@wordpress/i18n';\nimport { withSelect } from '@wordpress/data';\nimport { cloneElement } from '@wordpress/element';\nimport { ToggleControl, PanelBody } from '@wordpress/components';\n\nconst Video = {\n\t_init: function() {\n\t\tif ( typeof CLD_VIDEO_PLAYER === 'undefined' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Gutenberg Video Settings\n\t\twp.hooks.addFilter(\n\t\t\t'blocks.registerBlockType',\n\t\t\t'Cloudinary/Media/Video',\n\t\t\tfunction( settings, name ) {\n\t\t\t\tif ( name === 'core/video' ) {\n\t\t\t\t\tif ( 'off' !== CLD_VIDEO_PLAYER.video_autoplay_mode ) {\n\t\t\t\t\t\tsettings.attributes.autoplay.default = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( 'on' === CLD_VIDEO_PLAYER.video_loop ) {\n\t\t\t\t\t\tsettings.attributes.loop.default = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( 'off' === CLD_VIDEO_PLAYER.video_controls ) {\n\t\t\t\t\t\tsettings.attributes.controls.default = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn settings;\n\t\t\t}\n\t\t);\n\t},\n};\n\nexport default Video;\n\n// Init.\nVideo._init();\n\nlet cldAddToggle = function( settings, name ) {\n\n\tif ( 'core/image' === name || 'core/video' === name ) {\n\t\tif ( !settings.attributes ) {\n\t\t\tsettings.attributes = {};\n\t\t}\n\n\t\tsettings.attributes.overwrite_transformations = {\n\t\t\ttype: 'boolean',\n\t\t};\n\n\t\tsettings.attributes.transformations = {\n\t\t\ttype: 'boolean',\n\t\t};\n\n\t}\n\n\treturn settings;\n};\n\nwp.hooks.addFilter( 'blocks.registerBlockType', 'cloudinary/addAttributes', cldAddToggle );\n\n/**\n * Get AMP Lightbox toggle control.\n *\n * @param {Object} props Props.\n *\n * @return {Component} Element.\n */\nconst TransformationsToggle = ( props ) => {\n\tconst {attributes: {overwrite_transformations, transformations}, setAttributes} = props;\n\n\treturn (\n\t\t\n\t\t\t {\n\t\t\t\t\tsetAttributes( {overwrite_transformations: value} );\n\t\t\t\t}}\n\t\t\t/>\n\t\t\n\t);\n};\n\nlet ImageInspectorControls = ( props ) => {\n\tconst {setAttributes, media} = props;\n\tconst {InspectorControls} = wp.editor;\n\n\tif ( media && media.transformations ) {\n\t\tsetAttributes( {transformations: true} );\n\t}\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n};\n\nImageInspectorControls = withSelect( ( select, ownProps ) => ( {\n\t...ownProps,\n\tmedia: ownProps.attributes.id ? select( 'core' ).getMedia( ownProps.attributes.id ) : null\n} ))( ImageInspectorControls );\n\nconst cldFilterBlocksEdit = ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst {name} = props;\n\t\tconst shouldDisplayInspector = 'core/image' === name || 'core/video' === name;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{shouldDisplayInspector ? : null}\n\t\t\t\t\n\t\t\t\n\t\t);\n\t}\n};\n\nwp.hooks.addFilter( 'editor.BlockEdit', 'cloudinary/filterEdit', cldFilterBlocksEdit, 20 );\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","var defineProperty = require(\"./defineProperty\");\n\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? Object(arguments[i]) : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}\n\nmodule.exports = _objectSpread;","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"data\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./js/src/blocks.js","webpack:///./js/src/components/featured-image.js","webpack:///./js/src/components/video.js","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./node_modules/@babel/runtime/helpers/objectSpread.js","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"data\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}"],"names":["$","window","jQuery","cloudinaryBlocks","Video","Featured","FeaturedTransformationsToggle","props","modalClass","__","overwrite_featured_transformations","value","setOverwrite","withSelect","select","ownProps","getEditedPostAttribute","withDispatch","dispatch","editPost","meta","_cloudinary_featured_overwrite","cldFilterFeatured","BlockEdit","_init","wp","hooks","addFilter","CLD_VIDEO_PLAYER","settings","name","video_autoplay_mode","attributes","autoplay","default","video_loop","loop","video_controls","controls","cldAddToggle","overwrite_transformations","type","transformations","TransformationsToggle","setAttributes","ImageInspectorControls","media","InspectorControls","editor","id","getMedia","cldFilterBlocksEdit","shouldDisplayInspector"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFA;AAAA;AAAA;AAAA;AAAA;;AACA;;;AAIA;AACA;CAIA;;AACA,IAAMA,CAAC,GAAGC,MAAM,CAACD,CAAP,GAAWC,MAAM,CAACC,MAA5B,C,CAEA;;AACO,IAAMC,gBAAgB,GAAG;AAC/BC,OAAK,EAALA,yDAD+B;AAE/BC,UAAQ,EAARA,kEAAQA;AAFuB,CAAzB,C;;;;;;;;;;;;;;;;;;;;;;;ACdP;AAEA;AAEA;CAGA;;AACA,IAAIC,6BAA6B,GAAG,uCAAEC,KAAF,EAAa;AAE7C,SACI,4IACMA,KAAK,CAACC,UAAN,IACF,yEAAC,mEAAD;AACI,SAAK,EAAGC,0DAAE,CAAE,2BAAF,EAA+B,YAA/B,CADd;AAEI,WAAO,EAAGF,KAAK,CAACG,kCAFpB;AAGI,YAAQ,EAAG,kBAAEC,KAAF;AAAA,aAAaJ,KAAK,CAACK,YAAN,CAAoBD,KAApB,CAAb;AAAA;AAHf,IAFJ,CADJ;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AKA,IAAMM,mBAAmB,GAAG,SAAtBA,mBAAsB,CAAE5B,SAAF,EAAiB;AAC5C,SAAO,UAAEhB,KAAF,EAAa;AAAA,QACZuB,IADY,GACJvB,KADI,CACZuB,IADY;AAEnB,QAAMsB,sBAAsB,GAAG,iBAAiBtB,IAAjB,IAAyB,iBAAiBA,IAAzE;AAEA,WACC,4IACEsB,sBAAsB,GAAG,yEAAC,sBAAD,EAA4B7C,KAA5B,CAAH,GAA2C,IADnE,EAEC,yEAAC,SAAD,EAAeA,KAAf,CAFD,CADD;AAMA,GAVD;AAWA,CAZD;;AAcAkB,EAAE,CAACC,KAAH,CAASC,SAAT,CAAoB,kBAApB,EAAwC,uBAAxC,EAAiEwB,mBAAjE,EAAsF,EAAtF,E;;;;;;;;;;;ACzHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA,iC;;;;;;;;;;;ACfA,qBAAqB,mBAAO,CAAC,iFAAkB;;AAE/C;AACA,iBAAiB,sBAAsB;AACvC;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;AAEA,+B;;;;;;;;;;;ACrBA,aAAa,2CAA2C,EAAE,I;;;;;;;;;;;ACA1D,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,qCAAqC,EAAE,I","file":"block-editor.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./js/src/blocks.js\");\n","/* global window */\n/**\n * Main JS.\n */\n\n// Components\nimport Video from './components/video';\nimport Featured from './components/featured-image';\n\n\n// jQuery, because reasons.\nconst $ = window.$ = window.jQuery;\n\n// Global Constants\nexport const cloudinaryBlocks = {\n\tVideo,\n\tFeatured\n};\n\n","/* global window wp */\n\nimport { __ } from '@wordpress/i18n';\n\nimport { ToggleControl, PanelBody } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\n\n// Set our component.\nlet FeaturedTransformationsToggle = ( props ) => {\n\n return (\n <>\n { props.modalClass &&\n props.setOverwrite( value ) }\n />\n }\n \n );\n};\n\n// Setup our properties.\nFeaturedTransformationsToggle = withSelect( ( select, ownProps ) => ( {\n overwrite_featured_transformations: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ '_cloudinary_featured_overwrite' ] ?? false,\n} ) )( FeaturedTransformationsToggle );\n\n// Setup our update method.\nFeaturedTransformationsToggle = withDispatch(\n ( dispatch ) => {\n return {\n setOverwrite: ( value ) => {\n dispatch( 'core/editor' ).editPost( { meta: { _cloudinary_featured_overwrite: value } } );\n }\n };\n }\n)( FeaturedTransformationsToggle );\n\n// Hook in and add our component.\nconst cldFilterFeatured = ( BlockEdit ) => {\n return ( props ) => {\n // We only need this on a MediaUpload component that has a value.\n return (\n <>\n \n { !! props.value &&\n \n }\n \n );\n };\n};\n\n// Setup an init wrapper.\nconst Featured = {\n _init: function() {\n // Add it to Media Upload to allow for deeper connection with getting\n // the media object, to determine if an asset has transformations.\n // Also adds deeper support for other image types within Guttenberg.\n // @todo: find other locations (i.e Video poster).\n wp.hooks.addFilter( 'editor.MediaUpload', 'cloudinary/filter-featured-image', cldFilterFeatured );\n },\n};\n\n// Push Init.\nFeatured._init();\n\n// Export to keep it in scope.\nexport default Featured;\n","/* global window wp */\n\nimport { __ } from '@wordpress/i18n';\nimport { withSelect } from '@wordpress/data';\nimport { cloneElement } from '@wordpress/element';\nimport { ToggleControl, PanelBody } from '@wordpress/components';\n\nconst Video = {\n\t_init: function() {\n\t\tif ( typeof CLD_VIDEO_PLAYER === 'undefined' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Gutenberg Video Settings\n\t\twp.hooks.addFilter(\n\t\t\t'blocks.registerBlockType',\n\t\t\t'Cloudinary/Media/Video',\n\t\t\tfunction( settings, name ) {\n\t\t\t\tif ( name === 'core/video' ) {\n\t\t\t\t\tif ( 'off' !== CLD_VIDEO_PLAYER.video_autoplay_mode ) {\n\t\t\t\t\t\tsettings.attributes.autoplay.default = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( 'on' === CLD_VIDEO_PLAYER.video_loop ) {\n\t\t\t\t\t\tsettings.attributes.loop.default = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( 'off' === CLD_VIDEO_PLAYER.video_controls ) {\n\t\t\t\t\t\tsettings.attributes.controls.default = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn settings;\n\t\t\t}\n\t\t);\n\t},\n};\n\nexport default Video;\n\n// Init.\nVideo._init();\n\nlet cldAddToggle = function( settings, name ) {\n\n\tif ( 'core/image' === name || 'core/video' === name ) {\n\t\tif ( !settings.attributes ) {\n\t\t\tsettings.attributes = {};\n\t\t}\n\n\t\tsettings.attributes.overwrite_transformations = {\n\t\t\ttype: 'boolean',\n\t\t};\n\n\t\tsettings.attributes.transformations = {\n\t\t\ttype: 'boolean',\n\t\t};\n\n\t}\n\n\treturn settings;\n};\n\nwp.hooks.addFilter( 'blocks.registerBlockType', 'cloudinary/addAttributes', cldAddToggle );\n\n/**\n * Get AMP Lightbox toggle control.\n *\n * @param {Object} props Props.\n *\n * @return {Component} Element.\n */\nconst TransformationsToggle = ( props ) => {\n\tconst {attributes: {overwrite_transformations, transformations}, setAttributes} = props;\n\n\treturn (\n\t\t\n\t\t\t {\n\t\t\t\t\tsetAttributes( {overwrite_transformations: value} );\n\t\t\t\t}}\n\t\t\t/>\n\t\t\n\t);\n};\n\nlet ImageInspectorControls = ( props ) => {\n\tconst {setAttributes, media} = props;\n\tconst {InspectorControls} = wp.editor;\n\n\tif ( media && media.transformations ) {\n\t\tsetAttributes( {transformations: true} );\n\t}\n\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n};\n\nImageInspectorControls = withSelect( ( select, ownProps ) => ( {\n\t...ownProps,\n\tmedia: ownProps.attributes.id ? select( 'core' ).getMedia( ownProps.attributes.id ) : null\n} ))( ImageInspectorControls );\n\nconst cldFilterBlocksEdit = ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst {name} = props;\n\t\tconst shouldDisplayInspector = 'core/image' === name || 'core/video' === name;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{shouldDisplayInspector ? : null}\n\t\t\t\t\n\t\t\t\n\t\t);\n\t}\n};\n\nwp.hooks.addFilter( 'editor.BlockEdit', 'cloudinary/filterEdit', cldFilterBlocksEdit, 20 );\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","var defineProperty = require(\"./defineProperty\");\n\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? Object(arguments[i]) : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}\n\nmodule.exports = _objectSpread;","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"data\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());"],"sourceRoot":""} \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/featured-image.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/featured-image.js index c67c896e2..cc14a74d9 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/featured-image.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/featured-image.js @@ -10,11 +10,13 @@ let FeaturedTransformationsToggle = ( props ) => { return ( <> - props.setOverwrite( value ) } - /> + { props.modalClass && + props.setOverwrite( value ) } + /> + } ); };