diff --git a/assets/icon-128x128.png b/assets/icon-128x128.png index b077639f9..64cf12478 100644 Binary files a/assets/icon-128x128.png and b/assets/icon-128x128.png differ diff --git a/assets/icon-256x256.png b/assets/icon-256x256.png index e92c918e5..ae26625a3 100644 Binary files a/assets/icon-256x256.png and b/assets/icon-256x256.png differ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php index af7d1a8a7..7f19a1ab1 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php @@ -3,7 +3,7 @@ * Plugin Name: Cloudinary * Plugin URI: https://cloudinary.com/documentation/wordpress_integration * Description: With the Cloudinary plugin, you can upload and manage your media assets in the cloud, then deliver them to your users through a fast content delivery network, improving your website’s loading speed and overall user experience. Apply multiple transformations and take advantage of a full digital asset management solution without leaving WordPress. - * Version: 2.2.1 + * Version: 2.3.0 * Author: Cloudinary Ltd., XWP * Author URI: https://cloudinary.com/ * License: GPLv2+ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css index 01c670aae..bd5ca5198 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css @@ -1 +1 @@ -@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.7b8dc57b5dd3c69880043780bb9bb133.eot);src:url(../css/fonts/cloudinary.7b8dc57b5dd3c69880043780bb9bb133.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.0bf34bba6c50ef8a00885c94fc39bb81.ttf) format("truetype"),url(../css/fonts/cloudinary.130b5d626b226659422cfb0e20ce30c1.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.uploading{color:#fd9d2c}.dashicons-cloudinary.uploading:before{content:"\e902"}.dashicons-cloudinary.info{color:#0071ba}.dashicons-cloudinary.downloading:before{content:"\e903"}.dashicons-cloudinary.syncing:before{content:"\e904"}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0071ba}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error.expanded{padding-top:40px;margin-bottom:25px}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px;margin-bottom:25px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.settings-warning{display:inline-block;padding:5px 7px;background-color:#e9faff;border:1px solid #ccd0d4;border-left:4px solid #00a0d2;box-shadow:0 1px 1px rgba(0,0,0,.04)}.field-radio input[type=radio].cld-field{margin:0 5px 0 0}.field-radio label{margin-right:10px}.settings-tab-section h2{margin:0}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file +@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.7e6e75b25255a2b3b6e7ced1092c210c.eot);src:url(../css/fonts/cloudinary.7e6e75b25255a2b3b6e7ced1092c210c.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.c2afda9d25532c03cd41beb20a1ce439.ttf) format("truetype"),url(../css/fonts/cloudinary.34cb260ad722325c597cdc3a3e7584d8.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.uploading{color:#fd9d2c}.dashicons-cloudinary.uploading:before{content:"\e902"}.dashicons-cloudinary.info{color:#0071ba}.dashicons-cloudinary.downloading:before{content:"\e903"}.dashicons-cloudinary.syncing:before{content:"\e904"}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0071ba}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error.expanded{padding-top:40px;margin-bottom:25px}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px;margin-bottom:25px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.settings-warning{display:inline-block;padding:5px 7px;background-color:#e9faff;border:1px solid #ccd0d4;border-left:4px solid #00a0d2;box-shadow:0 1px 1px rgba(0,0,0,.04)}.field-radio input[type=radio].cld-field{margin:0 5px 0 0}.field-radio label{margin-right:10px}.settings-tab-section h2{margin:0}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.34cb260ad722325c597cdc3a3e7584d8.woff b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.34cb260ad722325c597cdc3a3e7584d8.woff new file mode 100644 index 000000000..2e398fcd5 Binary files /dev/null and b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.34cb260ad722325c597cdc3a3e7584d8.woff differ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.7e6e75b25255a2b3b6e7ced1092c210c.eot b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.7e6e75b25255a2b3b6e7ced1092c210c.eot new file mode 100644 index 000000000..b5d83bc15 Binary files /dev/null and b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.7e6e75b25255a2b3b6e7ced1092c210c.eot differ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.c2afda9d25532c03cd41beb20a1ce439.ttf b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.c2afda9d25532c03cd41beb20a1ce439.ttf new file mode 100644 index 000000000..166b4542d Binary files /dev/null and b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/fonts/cloudinary.c2afda9d25532c03cd41beb20a1ce439.ttf differ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_terms_order.scss b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_terms_order.scss index eeaf54b89..7d85be7c0 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_terms_order.scss +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_terms_order.scss @@ -39,7 +39,6 @@ } &-type { - width: 45%; display: inline-block; margin-right: 8px; 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..e005bc2a9 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":"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","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/cloudinary.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js index 07fdc13c6..0dd9eaf38 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js @@ -1 +1 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=4)}([function(e,t){!function(){const e=function(){const e=jQuery("#field-video_player").val(),t=jQuery("#field-video_controls").prop("checked"),i=jQuery('#field-video_autoplay_mode option[value="off"]');"cld"!==e||t?i.prop("disabled",!1):(i.prop("disabled",!0),i.prop("selected")&&i.next().prop("selected",!0))};e(),jQuery(document).on("change","#field-video_player",e),jQuery(document).on("change","#field-video_controls",e),jQuery(document).ready((function(e){e(document).on("tabs.init",(function(){var t=e(".settings-tab-trigger"),i=e(".settings-tab-section");e(this).on("click",".settings-tab-trigger",(function(n){var s=e(this),a=e(s.attr("href"));n.preventDefault(),t.removeClass("active"),i.removeClass("active"),s.addClass("active"),a.addClass("active"),e(document).trigger("settings.tabbed",s)})),e(".cld-field").not('[data-condition="false"]').each((function(){const t=e(this),i=t.data("condition");for(let n in i){const s=i[n],a=e("#field-"+n),o=t.closest("tr");a.on("change init",(function(){this.value===s||this.checked?o.show():o.hide()})),a.trigger("init")}})),e("#field-cloudinary_url").on("input change",(function(){let t=e(this),i=t.val();new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\/\/){1}(\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g).test(i)?(t.addClass("settings-valid-field"),t.removeClass("settings-invalid-field")):(t.removeClass("settings-valid-field"),t.addClass("settings-invalid-field"))})).trigger("change"),e('[name="cloudinary_sync_media[auto_sync]"]').change((function(){"on"===e(this).val()&&e("#auto-sync-alert-btn").click()}))})),e(".render-trigger[data-event]").each((function(){var t=e(this),i=t.data("event");t.trigger(i,this)}))}))}(window,jQuery)},function(e,t){if(wp.media&&window.CLDN){wp.media.events.on("editor:image-edit",(function(e){e.metadata.cldoverwrite=null,e.image.className.split(" ").indexOf("cld-overwrite")>=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,o=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a'+t),t=t.replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+n+'" data-lazy-src='))),t}(e);t.firstChild;)a||!o||void 0===i||!t.firstChild.tagName||"img"!==t.firstChild.tagName.toLowerCase()&&"iframe"!==t.firstChild.tagName.toLowerCase()||i.observe(t.firstChild),e.parentNode.insertBefore(t.firstChild,e);e.parentNode.removeChild(e)}function d(){document.querySelectorAll("noscript.loading-lazy").forEach(l),void 0!==window.matchMedia&&window.matchMedia("print").addListener((function(e){e.matches&&document.querySelectorAll(s.lazyImage+"[data-lazy-src],"+s.lazyIframe+"[data-lazy-src]").forEach((function(e){r(e)}))}))}"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(i=new IntersectionObserver((function(e,t){e.forEach((function(e){if(0!==e.intersectionRatio){var i=e.target;t.unobserve(i),r(i)}}))}),s)),n="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()},/comp|inter/.test(document.readyState)?n(d):"addEventListener"in document?document.addEventListener("DOMContentLoaded",(function(){n(d)})):document.attachEvent("onreadystatechange",(function(){"complete"===document.readyState&&d()}))}()},function(e,t,i){},function(e,t,i){"use strict";i.r(t);i(2);var n=i(0),s=i.n(n);const a={progress:document.getElementById("progress-wrapper"),submitButton:document.getElementById("submit"),stopButton:document.getElementById("stop-sync"),completed:document.getElementById("completed-notice"),show:"inline-block",hide:"none",isRunning:!1,getStatus:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/attachments";wp.ajax.send({url:e,type:"GET",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){a.isRunning=e.is_running,a.isRunning&&setTimeout(a.getStatus,1e4),a._updateUI(e)}))},stopSync:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/sync";a.isRunning=!1,wp.ajax.send({url:e,data:{stop:!0},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){a._updateUI(e)}))},pushAttachments:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/sync";a.isRunning=!0,a.progress.style.display=a.show,wp.ajax.send({url:e,beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){setTimeout(a.getStatus,1e4)}))},_updateUI:function(e){e.percent<100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.percent>=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,100===e.percent&&(this.completed.style.display=this.show),this.isRunning?this.progress.style.display=this.show:this.progress.style.display=this.hide},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var o=a;[...document.getElementsByClassName("cld-deactivate")].forEach(e=>{e.addEventListener("click",(function(e){confirm(wp.i18n.__('Caution: Your storage setting is currently set to "Cloudinary only", disabling the plugin will result in broken links to media assets. Are you sure you want to continue?',"cloudinary"))||e.preventDefault()}))}),a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var r=i(1),l=i.n(r);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),o=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${o})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var m=u;const p={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=p;p._init();const f={_init:function(){let e=this;if("undefined"!=typeof CLDIS){[...document.getElementsByClassName("cld-notice")].forEach(t=>{t.addEventListener("click",i=>{"notice-dismiss"===i.target.className&&e._dismiss(t)})})}},_dismiss:function(e){let t=e.dataset.dismiss,i=e.dataset.duration;wp.ajax.send({url:CLDIS.url,data:{token:t,duration:i,_wpnonce:CLDIS.nonce}})}};window.addEventListener("load",f._init());var g=f;i(3);i.d(t,"cloudinary",(function(){return y}));window.$=window.jQuery;const y={settings:s.a,sync:o,widget:l.a,Global_Transformations:c,Terms_Order:m,Media_Library:h,Notices:g}}]); \ No newline at end of file +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){!function(){const e=function(){const e=jQuery("#field-video_player").val(),t=jQuery("#field-video_controls").prop("checked"),n=jQuery('#field-video_autoplay_mode option[value="off"]');"cld"!==e||t?n.prop("disabled",!1):(n.prop("disabled",!0),n.prop("selected")&&n.next().prop("selected",!0))};e(),jQuery(document).on("change","#field-video_player",e),jQuery(document).on("change","#field-video_controls",e),jQuery(document).ready((function(e){e(document).on("tabs.init",(function(){var t=e(".settings-tab-trigger"),n=e(".settings-tab-section");e(this).on("click",".settings-tab-trigger",(function(i){var a=e(this),s=e(a.attr("href"));i.preventDefault(),t.removeClass("active"),n.removeClass("active"),a.addClass("active"),s.addClass("active"),e(document).trigger("settings.tabbed",a)})),e(".cld-field").not('[data-condition="false"]').each((function(){const t=e(this),n=t.data("condition");for(let i in n){const a=n[i],s=e("#field-"+i),r=t.closest("tr");s.on("change init",(function(){this.value===a||this.checked?r.show():r.hide()})),s.trigger("init")}})),e("#field-cloudinary_url").on("input change",(function(){let t=e(this),n=t.val();new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\/\/){1}(\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g).test(n)?(t.addClass("settings-valid-field"),t.removeClass("settings-invalid-field")):(t.removeClass("settings-valid-field"),t.addClass("settings-invalid-field"))})).trigger("change"),e('[name="cloudinary_sync_media[auto_sync]"]').change((function(){"on"===e(this).val()&&e("#auto-sync-alert-btn").click()}))})),e(".render-trigger[data-event]").each((function(){var t=e(this),n=t.data("event");t.trigger(n,this)}))}))}(window,jQuery)},function(e,t){if(wp.media&&window.CLDN){wp.media.events.on("editor:image-edit",(function(e){e.metadata.cldoverwrite=null,e.image.className.split(" ").indexOf("cld-overwrite")>=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(n,i){return n.cldoverwrite&&(n.classes=["cld-overwrite"],e=!0),t(n,i)},wp.media.post=function(t,n){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(n.attachment);t.attributes.transformations&&(n.attachment.transformations=t.attributes.transformations),(n.html.indexOf("cld-overwrite")>-1||!0===e)&&(n.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,n)};wp.media.controller.Library;let n=wp.media.view.MediaFrame.Select,i=wp.media.view.MediaFrame.Post,a=wp.media.view.MediaFrame.ImageDetails,s=wp.media.view.MediaFrame.VideoDetails,r=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),n=this.model.get("library"),i=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var a=i.get(t.models[0].id);void 0!==a.attributes.public_id&&(CLDN.mloptions.asset={resource_id:a.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(a){for(let s=0;s'+t),t=t.replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+i+'" data-lazy-src='))),t}(e);t.firstChild;)s||!r||void 0===n||!t.firstChild.tagName||"img"!==t.firstChild.tagName.toLowerCase()&&"iframe"!==t.firstChild.tagName.toLowerCase()||n.observe(t.firstChild),e.parentNode.insertBefore(t.firstChild,e);e.parentNode.removeChild(e)}function d(){document.querySelectorAll("noscript.loading-lazy").forEach(l),void 0!==window.matchMedia&&window.matchMedia("print").addListener((function(e){e.matches&&document.querySelectorAll(a.lazyImage+"[data-lazy-src],"+a.lazyIframe+"[data-lazy-src]").forEach((function(e){o(e)}))}))}"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(n=new IntersectionObserver((function(e,t){e.forEach((function(e){if(0!==e.intersectionRatio){var n=e.target;t.unobserve(n),o(n)}}))}),a)),i="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()},/comp|inter/.test(document.readyState)?i(d):"addEventListener"in document?document.addEventListener("DOMContentLoaded",(function(){i(d)})):document.attachEvent("onreadystatechange",(function(){"complete"===document.readyState&&d()}))}()},function(e,t,n){},,function(e,t,n){"use strict";n.r(t),n.d(t,"cloudinary",(function(){return y}));n(2);var i=n(0),a=n.n(i);const s={progress:document.getElementById("progress-wrapper"),submitButton:document.getElementById("submit"),stopButton:document.getElementById("stop-sync"),completed:document.getElementById("completed-notice"),show:"inline-block",hide:"none",isRunning:!1,getStatus:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/attachments";wp.ajax.send({url:e,type:"GET",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){s.isRunning=e.is_running,s.isRunning&&setTimeout(s.getStatus,1e4),s._updateUI(e)}))},stopSync:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/sync";s.isRunning=!1,wp.ajax.send({url:e,data:{stop:!0},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){s._updateUI(e)}))},pushAttachments:function(){var e=cloudinaryApi.restUrl+"cloudinary/v1/sync";s.isRunning=!0,s.progress.style.display=s.show,wp.ajax.send({url:e,beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",cloudinaryApi.nonce)}}).done((function(e){setTimeout(s.getStatus,1e4)}))},_updateUI:function(e){e.percent<100&&void 0!==e.started||e.percent>=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,100===e.percent&&(this.completed.style.display=this.show),this.isRunning?this.progress.style.display=this.show:this.progress.style.display=this.hide},_start:function(e){e.preventDefault(),s.stopButton.style.display=s.show,s.submitButton.style.display=s.hide,s.pushAttachments()},_reset:function(e){s.submitButton.style.display=s.hide,s.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var r=s;[...document.getElementsByClassName("cld-deactivate")].forEach(e=>{e.addEventListener("click",(function(e){confirm(wp.i18n.__('Caution: Your storage setting is currently set to "Cloudinary only", disabling the plugin will result in broken links to media assets. Are you sure you want to continue?',"cloudinary"))||e.preventDefault()}))}),s._init((function(){s._reset(),s.submitButton.addEventListener("click",s._start),s.stopButton.addEventListener("click",s.stopSync)}));var o=n(1),l=n.n(o);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let n=t.value.trim();if(n.length){if("select-one"===t.type){if("none"===n)continue;n=t.dataset.meta+"_"+n}else{let e=t.dataset.context;n=this._transformations(n,e,!0)}n&&this.elements[e].push(n)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let n=this,i=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+n.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){n.preview[t].src=this.src,n._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),n._clearLoading(t)},e.src=i}else{let e=n._transformations(n.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),n._clearLoading(t)}},_transformations:function(e,t,n=!1){let i=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,a=null,s=e.split("/"),r=[];for(let e=0;e{const i=!!n.length&&jQuery('[data-item="'+a+":"+n[0].id+'"]');i.length?i.remove():(jQuery(`.cld-tax-order-list-item:contains(${r})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),n=t.val(),i=t.is(":checked"),a=t.parent().text().trim();!0===i?e.tags.find(`[data-item="category:${n}"]`).length||e._pushItem("category:"+n,a):e.tags.find(`[data-item="category:${n}"]`).remove()}))},_createItem:function(e,t){const n=jQuery("
  • "),i=jQuery(""),a=jQuery("");return n.addClass("cld-tax-order-list-item").attr("data-item",e),a.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),n.append(i).append(t).append(a),n},_pushItem:function(e,t){let n=this._createItem(e,t);this.tags.append(n)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let n in t){const i=wp.data.select("core/editor").getEditedPostAttribute(t[n].rest_base);e[t[n].slug]=i}}));const t=wp.element.createElement,n=n=>{class i extends n{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const n=this.pickItem(t);n&&(e[this.props.slug].includes(n.id)?this.makeItem(n):this.removeItem(n))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let n in e)-1===this.state.selectedTerms.indexOf(e[n])&&(t=e[n]);else for(let n in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[n])&&(t=this.state.selectedTerms[n]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),n=jQuery(""),i=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),i.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(n).append(e.name).append(i),t}}return e=>t(i,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",n)}var m=u;const p={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var f=p;p._init();const h={_init:function(){let e=this;if("undefined"!=typeof CLDIS){[...document.getElementsByClassName("cld-notice")].forEach(t=>{t.addEventListener("click",n=>{"notice-dismiss"===n.target.className&&e._dismiss(t)})})}},_dismiss:function(e){let t=e.dataset.dismiss,n=e.dataset.duration;wp.ajax.send({url:CLDIS.url,data:{token:t,duration:n,_wpnonce:CLDIS.nonce}})}};window.addEventListener("load",h._init());var g=h;n(3);window.$=window.jQuery;const y={settings:a.a,sync:r,widget:l.a,Global_Transformations:c,Terms_Order:m,Media_Library:f,Notices:g}}]); \ 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 ) } + /> + } ); }; diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/video.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/video.js index 5496bb742..4173be757 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/video.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/video.js @@ -75,7 +75,7 @@ const TransformationsToggle = ( props ) => { return ( { setAttributes( {overwrite_transformations: value} ); diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php index 84e49ac7f..835136560 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php @@ -495,6 +495,7 @@ public function get_crop( $url, $attachment_id ) { // Make the WP Size array. $wp_size = array( 'wpsize' => $size_name, + 'file' => $size['file'], 'width' => $size['width'], 'height' => $size['height'], 'crop' => $cropped ? 'fill' : 'scale', @@ -604,9 +605,6 @@ public function get_transformations_from_string( $str, $type = 'image' ) { $transformation_chains = explode( '/', $str ); $transformations = array(); foreach ( $transformation_chains as $index => $chain ) { - if ( false !== strpos( $chain, 'wpsize' ) ) { - continue; // A wpsize is not a transformation. - } $items = explode( ',', $chain ); foreach ( $items as $item ) { $item = trim( $item ); @@ -635,7 +633,19 @@ public function attachment_url( $url, $attachment_id ) { if ( false !== $previous_url ) { return substr( $url, $previous_url ); } - if ( ! doing_action( 'wp_insert_post_data' ) && false === $this->in_downsize ) { + if ( + ! doing_action( 'wp_insert_post_data' ) + && false === $this->in_downsize + /** + * Filter doing upload. + * If so, return the default attachment URL. + * + * @param bool Default false. + * + * @return bool + */ + && ! apply_filters( 'cloudinary_doing_upload', false ) + ) { if ( $this->cloudinary_id( $attachment_id ) ) { $url = $this->cloudinary_url( $attachment_id ); } @@ -724,7 +734,7 @@ public function apply_default_transformations( array $transformations, $type = ' * * @return string The converted URL. */ - public function cloudinary_url( $attachment_id, $size = array(), $transformations = array(), $cloudinary_id = null, $overwrite_transformations = false, $clean = false ) { + public function cloudinary_url( $attachment_id, $size = array(), $transformations = array(), $cloudinary_id = null, $overwrite_transformations = false ) { if ( ! ( $cloudinary_id ) ) { $cloudinary_id = $this->cloudinary_id( $attachment_id ); @@ -744,13 +754,7 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation 'resource_type' => $resource_type, ); - // Check size and correct if string or size. - if ( is_string( $size ) || ( is_array( $size ) && 3 === count( $size ) ) ) { - $intermediate = image_get_intermediate_size( $attachment_id, $size ); - if ( is_array( $intermediate ) ) { - $size = $this->get_crop( $intermediate['url'], $attachment_id ); - } - } + $size = $this->prepare_size( $attachment_id, $size ); if ( false === $overwrite_transformations ) { $overwrite_transformations = $this->maybe_overwrite_featured_image( $attachment_id ); } @@ -770,7 +774,7 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation // Make a copy as not to destroy the options in \Cloudinary::cloudinary_url(). $args = $pre_args; - $url = $this->plugin->components['connect']->api->cloudinary_url( $cloudinary_id, $args, $size, $clean ); + $url = $this->plugin->components['connect']->api->cloudinary_url( $cloudinary_id, $args, $size ); // Check if this type is a preview only type. i.e PDF. if ( ! empty( $size ) && $this->is_preview_only( $attachment_id ) ) { @@ -789,6 +793,44 @@ public function cloudinary_url( $attachment_id, $size = array(), $transformation return apply_filters( 'cloudinary_converted_url', $url, $attachment_id, $pre_args ); } + /** + * Prepare the Size array for the Cloudinary URL API. + * + * @param int $attachment_id The attachment ID. + * @param array|string $size The size array or slug. + * + * @return array|string + */ + public function prepare_size( $attachment_id, $size ) { + // Check size and correct if string or size. + if ( empty( $size ) || 'full' === $size ) { + // Maybe get full size if scaled. + $meta = wp_get_attachment_metadata( $attachment_id, true ); + if ( ! empty( $meta['original_image'] ) ) { + $size = array( + 'width' => $meta['width'], + 'height' => $meta['height'], + 'full' => true, + ); + } + } elseif ( is_string( $size ) || ( is_array( $size ) && 3 === count( $size ) ) ) { + $intermediate = image_get_intermediate_size( $attachment_id, $size ); + if ( is_array( $intermediate ) ) { + $size = $this->get_crop( $intermediate['url'], $attachment_id ); + } + } elseif ( array_keys( $size ) === array( 0, 1 ) ) { + $size = array( + 'width' => $size[0], + 'height' => $size[1], + ); + if ( $size['width'] === $size['height'] ) { + $size['crop'] = 'fill'; + } + } + + return $size; + } + /** * Add domain to subdir. * @@ -998,7 +1040,7 @@ public function convert_url( $url, $attachment_id, $transformations = array(), $ } $size = $this->get_crop( $url, $attachment_id ); - return $this->cloudinary_url( $attachment_id, $size, $transformations, null, $overwrite_transformations, true ); + return $this->cloudinary_url( $attachment_id, $size, $transformations, null, $overwrite_transformations ); } /** @@ -1017,10 +1059,12 @@ public function image_srcset( $sources, $size_array, $image_src, $image_meta, $a if ( ! $cloudinary_id ) { return $sources; // Return WordPress default sources. } - // Get transformations from URL. - $transformations = $this->get_transformations_from_string( $image_src ); + // Get transformations if any. + $transformations = $this->get_post_meta( $attachment_id, Sync::META_KEYS['transformation'], true ); // Use Cloudinary breakpoints for same ratio. + $image_meta['overwrite_transformations'] = ! empty( $image_meta['overwrite_transformations'] ) ? $image_meta['overwrite_transformations'] : false; + if ( 'on' === $this->plugin->config['settings']['global_transformations']['enable_breakpoints'] && wp_image_matches_ratio( $image_meta['width'], $image_meta['height'], $size_array[0], $size_array[1] ) ) { $meta = $this->get_post_meta( $attachment_id, Sync::META_KEYS['breakpoints'], true ); if ( ! empty( $meta ) ) { @@ -1050,7 +1094,7 @@ function ( $item ) use ( $crop ) { 'width' => $breakpoint['width'], ); $sources[ $breakpoint['width'] ] = array( - 'url' => $this->cloudinary_url( $attachment_id, $size, $transformations, $cloudinary_id, true ), + 'url' => $this->cloudinary_url( $attachment_id, $size, $transformations, $cloudinary_id, $image_meta['overwrite_transformations'] ), 'descriptor' => 'w', 'value' => $breakpoint['width'], ); @@ -1076,35 +1120,13 @@ function ( $item ) use ( $crop ) { // Use current sources, but convert the URLS. foreach ( $sources as &$source ) { if ( ! $this->is_cloudinary_url( $source['url'] ) ) { - $source['url'] = $this->convert_url( $source['url'], $attachment_id, $transformations, true ); // Overwrite transformations applied, since the $transformations includes globals from the primary URL. + $source['url'] = $this->convert_url( $source['url'], $attachment_id, $transformations, $image_meta['overwrite_transformations'] ); // Overwrite transformations applied, since the $transformations includes globals from the primary URL. } } return $sources; } - /** - * Alter the image sizes metadata to match the Cloudinary ID so that WordPress can detect a matched source for responsive breakpoints. - * - * @param array $image_meta The image metadata array. - * @param array $size_array The size array. - * @param string $image_src The image src. - * @param int $attachment_id The attachment ID. - * - * @return array - */ - public function match_responsive_sources( $image_meta, $size_array, $image_src, $attachment_id ) { - if ( wp_attachment_is_image( $attachment_id ) && ! empty( $image_meta['sizes'] ) ) { - $cloudinary_id = $this->cloudinary_id( $attachment_id ); - if ( $cloudinary_id ) { - // Set the file to the Cloudinary ID so that it will be matched. - $image_meta['file'] = $cloudinary_id; - } - } - - return $image_meta; - } - /** * Check if a url is a cloudinary url or not. * @@ -1668,12 +1690,22 @@ public function get_context_options( $attachment_id ) { */ public function is_folder_synced( $attachment_id ) { - $return = true; // By default all assets in WordPress will be synced. + $is_folder_synced = true; // By default all assets in WordPress will be synced. if ( $this->sync->been_synced( $attachment_id ) ) { - $return = ! empty( $this->get_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], true ) ); + $is_folder_synced = ! empty( $this->get_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], true ) ); } - return $return; + /** + * Filter is folder synced flag. + * + * @param bool $is_folder_synced Flag value for is folder sync. + * @param int $attachment_id The attachment ID. + * + * @return bool + */ + $is_folder_synced = apply_filters( 'cloudinary_is_folder_synced', $is_folder_synced, $attachment_id ); + + return (bool) $is_folder_synced; } /** @@ -1789,8 +1821,6 @@ public function setup() { // Filter live URLS. (functions that return a URL). add_filter( 'wp_calculate_image_srcset', array( $this, 'image_srcset' ), 10, 5 ); - add_filter( 'wp_calculate_image_srcset_meta', array( $this, 'match_responsive_sources' ), 10, 4 ); - add_filter( 'wp_get_attachment_metadata', array( $this, 'match_file_name_with_cloudinary_source' ), 10, 2 ); add_filter( 'wp_get_attachment_url', array( $this, 'attachment_url' ), 10, 2 ); add_filter( 'image_downsize', array( $this, 'filter_downsize' ), 10, 3 ); @@ -1802,23 +1832,4 @@ public function setup() { add_action( 'begin_fetch_post_thumbnail_html', array( $this, 'set_doing_featured' ), 10, 2 ); } } - - /** - * Ensure the file in image meta is the same as the Cloudinary ID. - * - * @param array $image_meta Meta information of the attachment. - * @param int $attachment_id The attachment ID. - * - * @return array - */ - public function match_file_name_with_cloudinary_source( $image_meta, $attachment_id ) { - if ( ! empty( $image_meta['file'] ) && $this->has_public_id( $attachment_id ) ) { - $cld_file = 'v' . $this->get_cloudinary_version( $attachment_id ) . '/' . $this->get_cloudinary_id( $attachment_id ); - if ( false === strpos( $image_meta['file'], $cld_file ) ) { - $image_meta['file'] = $cld_file; - } - } - - return $image_meta; - } } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index aafb13241..3d8a44463 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -262,7 +262,7 @@ public function get_signature( $attachment_id, $cached = true ) { if ( ! empty( $signatures[ $attachment_id ] ) && true === $cached ) { $return = $signatures[ $attachment_id ]; } else { - $signature = $this->managers['media']->get_post_meta( $attachment_id, self::META_KEYS['signature'], true ); + $signature = (array) $this->managers['media']->get_post_meta( $attachment_id, self::META_KEYS['signature'], true ); if ( empty( $signature ) ) { $signature = array(); } @@ -286,9 +286,13 @@ public function get_signature( $attachment_id, $cached = true ) { public function generate_public_id( $attachment_id ) { $cld_folder = $this->managers['media']->get_cloudinary_folder(); - $file = get_attached_file( $attachment_id ); - $file_info = pathinfo( $file ); - $public_id = $cld_folder . $file_info['filename']; + if ( wp_attachment_is_image( $attachment_id ) ) { + $file = wp_get_original_image_path( $attachment_id ); + } else { + $file = get_attached_file( $attachment_id ); + } + $file_info = pathinfo( $file ); + $public_id = $cld_folder . $file_info['filename']; return ltrim( $public_id, '/' ); } @@ -758,6 +762,10 @@ public function set_signature_item( $attachment_id, $type, $value = null ) { // Generate a new value based on generator. $value = $this->generate_type_signature( $type, $attachment_id ); } + // Ensure we have an array. + if ( empty( $meta[ Sync::META_KEYS['cloudinary'] ][ Sync::META_KEYS['signature'] ] ) || ! is_array( $meta[ Sync::META_KEYS['cloudinary'] ][ Sync::META_KEYS['signature'] ] ) ) { + $meta[ Sync::META_KEYS['cloudinary'] ][ Sync::META_KEYS['signature'] ] = array(); + } $meta[ Sync::META_KEYS['cloudinary'] ][ Sync::META_KEYS['signature'] ][ $type ] = $value; wp_update_attachment_metadata( $attachment_id, $meta ); } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php index 2bee4bed6..27ce0434f 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php @@ -96,7 +96,6 @@ class Api { 'pg' => 'page', 'sp' => 'streaming_profile', 'vs' => 'video_sampling', - '$wpsize' => 'wpsize', ), 'video' => array( 'w' => 'width', @@ -141,7 +140,7 @@ class Api { * @param string The plugin version. */ public function __construct( $connect, $version ) { - $this->credentials = $connect->get_credentials(); + $this->credentials = $connect->get_credentials(); $this->plugin_version = $version; // Use CNAME. if ( ! empty( $this->credentials['cname'] ) ) { @@ -172,8 +171,12 @@ public function url( $resource, $function = null, $endpoint = false ) { $parts[] = $this->credentials['cloud_name']; } - $parts[] = $resource; - $parts[] = $function; + if ( false === $endpoint && 'image' === $resource ) { + $parts[] = 'images'; + } else { + $parts[] = $resource; + $parts[] = $function; + } $parts = array_filter( $parts ); $url = implode( '/', $parts ); @@ -203,14 +206,6 @@ function ( $item ) use ( $transformation_index ) { foreach ( $item as $type => $value ) { // phpcs:ignore $key = array_search( $type, $transformation_index, true ); - if ( false !== strpos( $type, 'wpsize' ) ) { - if ( ! empty( $item['clean'] ) ) { - continue; - } - - $value = '!' . $value . '!'; - } - if ( false !== $key ) { $transform[] = $key . '_' . $value; } @@ -231,13 +226,13 @@ function ( $item ) use ( $transformation_index ) { * Generate a Cloudinary URL. * * @param string|null $public_id The Public ID to get a url for. - * @param array $args Additional args. - * @param array $size The WP Size array. - * @param bool $clean Flag to produce a non variable size url. + * @param array $args Additional args. + * @param array $size The WP Size array. + * @param bool $clean Flag to produce a non variable size url. * * @return string */ - public function cloudinary_url( $public_id = null, $args = array(), $size = array(), $clean = false ) { + public function cloudinary_url( $public_id = null, $args = array(), $size = array() ) { if ( null === $public_id ) { return 'https://' . $this->url( null, null ); @@ -267,22 +262,18 @@ public function cloudinary_url( $public_id = null, $args = array(), $size = arra if ( ! empty( $args['transformation'] ) ) { $url_parts[] = self::generate_transformation_string( $args['transformation'] ); } - + $base = pathinfo( $public_id ); + if ( 'image' === $args['resource_type'] ) { + $new_path = $base['filename'] . '/' . $base['basename']; + $public_id = str_replace( $base['basename'], $new_path, $public_id ); + } // Add size. if ( ! empty( $size ) && is_array( $size ) ) { - if ( true === $clean ) { - $size['clean'] = true; - } - if ( array_keys( $size ) == array( 0, 1 ) ) { - $size = array( - 'width' => $size[0], - 'height' => $size[1], - ); - if ( $size['width'] === $size['height'] ) { - $size['crop'] = 'fill'; - } - } $url_parts[] = self::generate_transformation_string( array( $size ) ); + // add size to ID if scaled. + if ( ! empty( $size['file'] ) ) { + $public_id = str_replace( $base['basename'], $size['file'], $public_id ); + } } $url_parts[] = $args['version']; @@ -408,29 +399,35 @@ public function upload_large( $attachment_id, $args ) { * @param int $attachment_id Attachment ID to upload. * @param array $args Array of upload options. * @param array $headers Additional headers to use in upload. + * @param bool $try_remote Flag to try_remote upload. * * @return array|\WP_Error */ - public function upload( $attachment_id, $args, $headers = array() ) { + public function upload( $attachment_id, $args, $headers = array(), $try_remote = true ) { $resource = ! empty( $args['resource_type'] ) ? $args['resource_type'] : 'image'; $resource = $this->convert_resource_type( $resource ); $url = $this->url( $resource, 'upload', true ); $args = $this->clean_args( $args ); $disable_https_fetch = get_transient( '_cld_disable_http_upload' ); - $file_url = wp_get_attachment_url( $attachment_id ); - $media = get_plugin_instance()->get_component( 'media' ); + if ( wp_attachment_is_image( $attachment_id ) ) { + $file_url = wp_get_original_image_url( $attachment_id ); + } else { + $file_url = wp_get_attachment_url( $attachment_id ); + } + $media = get_plugin_instance()->get_component( 'media' ); + $tempfile = false; if ( $media && $media->is_cloudinary_url( $file_url ) ) { // If this is a Cloudinary URL, then we can use it to fetch from that location. $disable_https_fetch = false; } // Check if we can try http file upload. - if ( empty( $headers ) && empty( $disable_https_fetch ) ) { + if ( empty( $headers ) && empty( $disable_https_fetch ) && true === $try_remote ) { $args['file'] = $file_url; } else { // We should have the file in args at this point, but if the transient was set, it will be defaulting here. if ( empty( $args['file'] ) ) { - $args['file'] = get_attached_file( $attachment_id ); + $args['file'] = wp_get_original_image_path( $attachment_id ); } // Headers indicate chunked upload. if ( empty( $headers ) ) { @@ -439,7 +436,6 @@ public function upload( $attachment_id, $args, $headers = array() ) { return $this->upload_large( $attachment_id, $args ); } } - $tempfile = false; if ( false !== strpos( $args['file'], 'vip://' ) ) { $args['file'] = $this->create_local_copy( $args['file'] ); if ( is_wp_error( $args['file'] ) ) { @@ -466,7 +462,7 @@ public function upload( $attachment_id, $args, $headers = array() ) { // Hook in flag to allow for non accessible URLS. if ( is_wp_error( $result ) ) { $error = $result->get_error_message(); - $code = $result->get_error_code(); + $code = $result->get_error_code(); /** * If there's an error and the file is a URL in the error message, * it's likely due to CURL or the location does not support URL file attachments. diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php index 580a87644..2837ca47a 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-filter.php @@ -266,13 +266,6 @@ public function filter_out_cloudinary( $data ) { if ( $this->media->is_cloudinary_url( $local_url ) ) { continue; } - $inherit_transformations = $this->media->get_transformation_from_meta( $attachment_id ); - $transformations = $this->media->get_transformations_from_string( $url ); - $transformations = array_filter( $transformations ); - if ( ! empty( $transformations ) && $inherit_transformations !== $transformations ) { - $transformations = Api::generate_transformation_string( $transformations ); - $local_url = add_query_arg( 'cld_params', $transformations, $local_url ); - } // Replace old tag. $content = str_replace( $url, $local_url, $content ); @@ -325,25 +318,20 @@ public function filter_out_local( $content ) { wp_parse_str( $query, $args ); $transformations = $this->media->get_transformations_from_string( $args['cld_params'] ); } - // Get the WP size from the class name. - $wp_size = $this->get_size_from_image_tag( $asset ); + $wp_size = $this->media->get_crop( $url, $attachment_id ); if ( false === $wp_size ) { // No class name, so get size from the width and height tags. $wp_size = $this->get_crop_from_image_tag( $asset ); - if ( empty( $wp_size ) ) { - $wp_size = 'full'; // Fallback to full if nothing is found at all. - } } // Get a cloudinary URL. - $clean = ! is_admin(); // Front facing images must not contain a wpsize url variable. $classes = $this->get_classes( $asset ); // check if this is a transformation overwrite. $overwrite_transformations = false; if ( false !== strpos( $classes, 'cld-overwrite' ) ) { $overwrite_transformations = true; } - $cloudinary_url = $this->media->cloudinary_url( $attachment_id, $wp_size, $transformations, null, $overwrite_transformations, $clean ); + $cloudinary_url = $this->media->cloudinary_url( $attachment_id, $wp_size, $transformations, null, $overwrite_transformations ); if ( $url === $cloudinary_url ) { continue; @@ -352,32 +340,35 @@ public function filter_out_local( $content ) { // Replace old tag. $new_tag = str_replace( $url, $cloudinary_url, $asset ); - // Check if there is a class set. ( for srcset images in case of a manual url added ). - if ( false === strpos( $new_tag, ' class=' ) && ! is_admin() ) { - // Add in the class name. - $new_tag = str_replace( '/>', ' class="wp-image-' . $attachment_id . '"/>', $new_tag ); - } - - // Apply lazy loading attribute - if ( - apply_filters( 'wp_lazy_loading_enabled', true ) && - false === strpos( $new_tag, 'loading="lazy"' ) && - $clean - ) { - $new_tag = str_replace( '/>', ' loading="lazy" />', $new_tag ); - } + // Add front end features. + if ( ! is_admin() ) { + // Check if there is a class set. ( for srcset images in case of a manual url added ). + if ( false === strpos( $new_tag, ' class=' ) ) { + // Add in the class name. + $new_tag = str_replace( '/>', ' class="wp-image-' . $attachment_id . '"/>', $new_tag ); + } + // Apply lazy loading attribute + if ( apply_filters( 'wp_lazy_loading_enabled', true ) && false === strpos( $new_tag, 'loading="lazy"' ) ) { + $new_tag = str_replace( '/>', ' loading="lazy" />', $new_tag ); + } - // If Cloudinary player is active, this is replaced there. - if ( ! $this->media->video->player_enabled() ) { - $poster = $this->get_poster_from_tag( $asset ); - if ( false !== $poster ) { - $post_attachment_id = $this->media->get_id_from_url( $poster ); - $cloudinary_url = $this->media->cloudinary_url( $post_attachment_id ); - $new_tag = str_replace( $poster, $cloudinary_url, $new_tag ); + // If Cloudinary player is active, this is replaced there. + if ( ! $this->media->video->player_enabled() ) { + $poster = $this->get_poster_from_tag( $asset ); + if ( false !== $poster ) { + $post_attachment_id = $this->media->get_id_from_url( $poster ); + $cloudinary_url = $this->media->cloudinary_url( $post_attachment_id ); + $new_tag = str_replace( $poster, $cloudinary_url, $new_tag ); + } } + $image_meta = wp_get_attachment_metadata( $attachment_id ); + $image_meta['file'] = pathinfo( $cloudinary_id, PATHINFO_FILENAME ) . '/' . pathinfo( $cloudinary_id, PATHINFO_BASENAME ); + $image_meta['overwrite_transformations'] = $overwrite_transformations; + $new_tag = wp_image_add_srcset_and_sizes( $new_tag, $image_meta, $attachment_id ); } - $content = str_replace( $asset, $new_tag, $content ); + // Additional URL change for backgrounds etc.. + $content = str_replace( $url, $cloudinary_url, $content ); } return $this->filter_video_shortcodes( $content ); @@ -595,7 +586,7 @@ private function template_overwrite_insert() { return '<# if( data.attachment.attributes.transformations ) { #>
    @@ -611,7 +602,7 @@ private function template_overwrite_insert_video() { return '<# if( \'video\' === data.type && data.attachment.attributes.transformations ) { #>
    @@ -629,7 +620,7 @@ private function template_overwrite_edit() { <# } #>'; @@ -645,7 +636,7 @@ private function template_overwrite_video_edit() {
    <# } #>'; @@ -730,7 +721,7 @@ public function setup_hooks() { // Filter URLS within content. add_action( 'wp_insert_post_data', array( $this, 'filter_out_cloudinary' ) ); add_filter( 'the_editor_content', array( $this, 'filter_out_local' ) ); - add_filter( 'the_content', array( $this, 'filter_out_local' ), 9 ); // Early to hook before responsive srcsets. + add_filter( 'the_content', array( $this, 'filter_out_local' ), 100 ); add_filter( 'wp_prepare_attachment_for_js', array( $this, 'filter_attachment_for_js' ), 11 ); // Add support for custom header. @@ -738,6 +729,7 @@ public function setup_hooks() { // Add transformations. add_filter( 'media_send_to_editor', array( $this, 'transform_to_editor' ), 10, 3 ); + // Filter video codes. add_filter( 'media_send_to_editor', array( $this, 'filter_video_embeds' ), 10, 3 ); @@ -752,5 +744,15 @@ public function setup_hooks() { // Filter for block rendering. add_filter( 'render_block_data', array( $this, 'filter_image_block_pre_render' ), 10, 2 ); + + // Cancel out breakpoints till later. + add_filter( + 'wp_img_tag_add_srcset_and_sizes_attr', + function ( $add, $image, $context, $attachment_id ) { + return ! $this->media->has_public_id( $attachment_id ); + }, + 10, + 4 + ); } } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-global-transformations.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-global-transformations.php index 77def1780..65ae8f5d2 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-global-transformations.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-global-transformations.php @@ -402,11 +402,14 @@ private function init_taxonomy_manager( $post ) { } } $out[] = ''; + // Get apply Type. - $type = get_post_meta( $post->ID, self::META_APPLY_KEY . '_terms', true ); - $out[] = ''; + if ( ! empty( $terms ) ) { + $type = get_post_meta( $post->ID, self::META_APPLY_KEY . '_terms', true ); + $out[] = ''; + } + $out[] = ''; - return implode( $out ); } @@ -501,7 +504,7 @@ public function classic_overwrite_transformations_featured_image( $content, $pos '

    ', esc_attr( self::META_FEATURED_IMAGE_KEY ), checked( $field_value, 1, false ), - esc_html__( 'Overwrite Transformations', 'cloudinary' ) + esc_html__( 'Overwrite Global Transformations', 'cloudinary' ) ); } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php index d5ab87c82..0e9f17673 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php @@ -185,12 +185,13 @@ function ( $val ) use ( $media ) { /** * Download an attachment source to the file system. * - * @param int $attachment_id The attachment ID. - * @param string $source The optional source to download. + * @param int $attachment_id The attachment ID. + * @param string $source The optional source to download. + * @param string|null $date The date of the attachment to set storage folders. * * @return array|\WP_Error */ - public function download_asset( $attachment_id, $source = null ) { + public function download_asset( $attachment_id, $source = null, $date = null ) { require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; if ( empty( $source ) ) { @@ -200,7 +201,7 @@ public function download_asset( $attachment_id, $source = null ) { $file_name = basename( $source ); try { // Prime a file to stream to. - $upload = wp_upload_bits( $file_name, null, 'temp' ); + $upload = wp_upload_bits( $file_name, null, 'temp', $date ); if ( ! empty( $upload['error'] ) ) { return new \WP_Error( 'download_error', $upload['error'] ); } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-storage.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-storage.php index 0d69186f4..795d5054c 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-storage.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-storage.php @@ -160,7 +160,15 @@ public function validate_file_folder_sync( $attachment_id ) { * @return string */ public function generate_signature( $attachment_id ) { - return $this->settings['offload'] . $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['public_id'], true ); + $file_exists = true; + if ( $this->settings['offload'] !== 'cld' ) { + $attachment_file = get_attached_file( $attachment_id ); + if ( ! file_exists( $attachment_file ) ) { + $file_exists = $attachment_file; + } + } + + return $this->settings['offload'] . $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['public_id'], true ) . $file_exists; } /** @@ -184,13 +192,14 @@ public function sync( $attachment_id ) { // Add low quality transformations. $transformations[] = array( 'quality' => 'auto:low' ); } - $url = $this->media->cloudinary_url( $attachment_id, '', $transformations, null, false, true ); + $url = $this->media->cloudinary_url( $attachment_id, '', $transformations, null, false ); break; case 'dual_full': - if ( ! empty( $previous_state ) && 'dual_full' !== $previous_state ) { + $exists = get_attached_file( $attachment_id ); + if ( ! empty( $previous_state ) && ! file_exists( $exists ) ) { // Only do this is it's changing a state. $transformations = $this->media->get_transformation_from_meta( $attachment_id ); - $url = $this->media->cloudinary_url( $attachment_id, '', $transformations, null, false, false ); + $url = $this->media->cloudinary_url( $attachment_id, '', $transformations, null, false ); } break; } @@ -201,7 +210,8 @@ public function sync( $attachment_id ) { if ( 'cld' !== $previous_state ) { $this->remove_local_assets( $attachment_id ); } - $this->download->download_asset( $attachment_id, $url ); + $date = get_post_datetime( $attachment_id ); + $this->download->download_asset( $attachment_id, $url, $date->format( 'Y/m' ) ); } $this->sync->set_signature_item( $attachment_id, 'storage' ); diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index fbacfc049..c4d29cbed 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -201,9 +201,25 @@ public function setup() { */ public function upload_asset( $attachment_id ) { - $type = $this->sync->get_sync_type( $attachment_id ); - $options = $this->media->get_upload_options( $attachment_id ); - $public_id = $options['public_id']; + add_filter( 'cloudinary_doing_upload', '__return_true' ); + + add_filter( + 'cloudinary_is_folder_synced', + function( $is_synced, $post_id ) use ( $attachment_id ) { + if ( $post_id === $attachment_id ) { + return true; + } + + return $is_synced; + }, + 10, + 2 + ); + + $type = $this->sync->get_sync_type( $attachment_id ); + $options = $this->media->get_upload_options( $attachment_id ); + $public_id = $options['public_id']; + $try_remote = 'cloud_name' === $type ? false : true; // Add the suffix before uploading. if ( $this->media->get_public_id( $attachment_id ) === $public_id ) { @@ -215,7 +231,9 @@ public function upload_asset( $attachment_id ) { } // Run the upload Call. - $result = $this->connect->api->upload( $attachment_id, $options ); + $result = $this->connect->api->upload( $attachment_id, $options, array(), $try_remote ); + + remove_filter( 'cloudinary_doing_upload', '__return_true' ); if ( ! is_wp_error( $result ) ) { @@ -233,7 +251,6 @@ public function upload_asset( $attachment_id ) { } } - // Set folder Synced. $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], $this->media->is_folder_synced( $attachment_id ) ); // Set public_id. diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/dashboard-content.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/dashboard-content.php index 804a59a5c..08bc3313b 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/dashboard-content.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/dashboard-content.php @@ -86,7 +86,9 @@

    -

    + is_connected() ): ?> +

    +