From 84733e9b2a02a7980e25fc6f322695c9538d5737 Mon Sep 17 00:00:00 2001
From: pini-girit
Date: Thu, 5 Aug 2021 15:26:35 +0300
Subject: [PATCH 01/11] v1.17.0,CLOUDINARY-332: Added analytics param to PG
asset URLs
---
Helper/ProductGalleryHelper.php | 1 +
composer.json | 2 +-
etc/module.xml | 2 +-
marketplace.composer.json | 30 +++++++++++++++---------------
4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/Helper/ProductGalleryHelper.php b/Helper/ProductGalleryHelper.php
index 9e9c309e..8e3103ca 100644
--- a/Helper/ProductGalleryHelper.php
+++ b/Helper/ProductGalleryHelper.php
@@ -94,6 +94,7 @@ public function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = false
unset($this->cloudinaryPGoptions['custom_free_params']);
}
$this->cloudinaryPGoptions['cloudName'] = $this->getCloudName();
+ $this->cloudinaryPGoptions['queryParam'] = 'AB';
}
return $this->cloudinaryPGoptions;
diff --git a/composer.json b/composer.json
index cb537ae0..4b1b87b6 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "cloudinary/cloudinary-magento2",
"description": "Cloudinary Magento 2 Integration.",
"type": "magento2-module",
- "version": "1.16.1",
+ "version": "1.17.0",
"license": "MIT",
"require": {
"cloudinary/cloudinary_php": "^1.20.0"
diff --git a/etc/module.xml b/etc/module.xml
index 9f637331..a4b59f0d 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/marketplace.composer.json b/marketplace.composer.json
index 7f77c212..d1f80080 100644
--- a/marketplace.composer.json
+++ b/marketplace.composer.json
@@ -1,18 +1,18 @@
{
- "name": "cloudinary/cloudinary",
- "description": "Cloudinary Magento 2 Integration.",
- "type": "magento2-module",
- "version": "1.16.1",
- "license": "MIT",
- "require": {
- "cloudinary/cloudinary_php": "^1.20.0"
- },
- "autoload": {
- "files": [
- "registration.php"
- ],
- "psr-4": {
- "Cloudinary\\Cloudinary\\": ""
- }
+ "name": "cloudinary/cloudinary",
+ "description": "Cloudinary Magento 2 Integration.",
+ "type": "magento2-module",
+ "version": "1.17.0",
+ "license": "MIT",
+ "require": {
+ "cloudinary/cloudinary_php": "^1.20.0"
+ },
+ "autoload": {
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Cloudinary\\Cloudinary\\": ""
}
+ }
}
\ No newline at end of file
From 35f597b822b8a26c7c82f61ca27a12e2a21fc554 Mon Sep 17 00:00:00 2001
From: pini-girit
Date: Thu, 12 Aug 2021 10:43:11 +0300
Subject: [PATCH 02/11] v1.17.0: Updated CLD Logos
---
view/adminhtml/web/css/source/_module.less | 4 +-
.../images/cloudinary_cloud_glyph_regular.svg | 1 +
.../images/cloudinary_cloud_glyph_white.svg | 1 +
.../images/cloudinary_icon_for_blue_bg.svg | 69 ------
.../images/cloudinary_icon_for_dark_bg.svg | 69 ------
.../images/cloudinary_icon_for_white_bg.svg | 69 ------
.../images/cloudinary_logo_for_blue_bg.svg | 188 ----------------
.../images/cloudinary_logo_for_dark_bg.svg | 188 ----------------
.../images/cloudinary_logo_for_white_bg.svg | 188 ----------------
.../cloudinary_vertical_logo_for_blue_bg.svg | 203 ------------------
.../cloudinary_vertical_logo_for_dark_bg.svg | 203 ------------------
.../cloudinary_vertical_logo_for_white_bg.svg | 203 ------------------
12 files changed, 4 insertions(+), 1382 deletions(-)
create mode 100644 view/base/web/images/cloudinary_cloud_glyph_regular.svg
create mode 100644 view/base/web/images/cloudinary_cloud_glyph_white.svg
delete mode 100644 view/base/web/images/cloudinary_icon_for_blue_bg.svg
delete mode 100644 view/base/web/images/cloudinary_icon_for_dark_bg.svg
delete mode 100644 view/base/web/images/cloudinary_icon_for_white_bg.svg
delete mode 100644 view/base/web/images/cloudinary_logo_for_blue_bg.svg
delete mode 100644 view/base/web/images/cloudinary_logo_for_dark_bg.svg
delete mode 100644 view/base/web/images/cloudinary_logo_for_white_bg.svg
delete mode 100644 view/base/web/images/cloudinary_vertical_logo_for_blue_bg.svg
delete mode 100644 view/base/web/images/cloudinary_vertical_logo_for_dark_bg.svg
delete mode 100644 view/base/web/images/cloudinary_vertical_logo_for_white_bg.svg
diff --git a/view/adminhtml/web/css/source/_module.less b/view/adminhtml/web/css/source/_module.less
index 642d941f..b3e98a91 100644
--- a/view/adminhtml/web/css/source/_module.less
+++ b/view/adminhtml/web/css/source/_module.less
@@ -1,5 +1,5 @@
.cloudinary-configuration-tab .admin__page-nav-title strong:before {
- background-image: url("Cloudinary_Cloudinary::images/cloudinary_icon_for_white_bg.svg");
+ background-image: url("Cloudinary_Cloudinary::images/cloudinary_cloud_glyph_regular.svg");
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
@@ -31,7 +31,7 @@
padding: 6px 14px 6px 50px;
&:before {
- background-image: url("Cloudinary_Cloudinary::images/cloudinary_icon_for_blue_bg.svg");
+ background-image: url("Cloudinary_Cloudinary::images/cloudinary_cloud_glyph_white.svg");
background-repeat: no-repeat;
background-size: contain;
background-position: center;
diff --git a/view/base/web/images/cloudinary_cloud_glyph_regular.svg b/view/base/web/images/cloudinary_cloud_glyph_regular.svg
new file mode 100644
index 00000000..a284090d
--- /dev/null
+++ b/view/base/web/images/cloudinary_cloud_glyph_regular.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/view/base/web/images/cloudinary_cloud_glyph_white.svg b/view/base/web/images/cloudinary_cloud_glyph_white.svg
new file mode 100644
index 00000000..5a108827
--- /dev/null
+++ b/view/base/web/images/cloudinary_cloud_glyph_white.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/view/base/web/images/cloudinary_icon_for_blue_bg.svg b/view/base/web/images/cloudinary_icon_for_blue_bg.svg
deleted file mode 100644
index 8a5c6c4b..00000000
--- a/view/base/web/images/cloudinary_icon_for_blue_bg.svg
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_icon_for_dark_bg.svg b/view/base/web/images/cloudinary_icon_for_dark_bg.svg
deleted file mode 100644
index 0dae7c93..00000000
--- a/view/base/web/images/cloudinary_icon_for_dark_bg.svg
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_icon_for_white_bg.svg b/view/base/web/images/cloudinary_icon_for_white_bg.svg
deleted file mode 100644
index 0dae7c93..00000000
--- a/view/base/web/images/cloudinary_icon_for_white_bg.svg
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_logo_for_blue_bg.svg b/view/base/web/images/cloudinary_logo_for_blue_bg.svg
deleted file mode 100644
index 72b86b0e..00000000
--- a/view/base/web/images/cloudinary_logo_for_blue_bg.svg
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_logo_for_dark_bg.svg b/view/base/web/images/cloudinary_logo_for_dark_bg.svg
deleted file mode 100644
index 58bc88be..00000000
--- a/view/base/web/images/cloudinary_logo_for_dark_bg.svg
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_logo_for_white_bg.svg b/view/base/web/images/cloudinary_logo_for_white_bg.svg
deleted file mode 100644
index f5e2b106..00000000
--- a/view/base/web/images/cloudinary_logo_for_white_bg.svg
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_vertical_logo_for_blue_bg.svg b/view/base/web/images/cloudinary_vertical_logo_for_blue_bg.svg
deleted file mode 100644
index c29c5e7c..00000000
--- a/view/base/web/images/cloudinary_vertical_logo_for_blue_bg.svg
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_vertical_logo_for_dark_bg.svg b/view/base/web/images/cloudinary_vertical_logo_for_dark_bg.svg
deleted file mode 100644
index 73618ee0..00000000
--- a/view/base/web/images/cloudinary_vertical_logo_for_dark_bg.svg
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/view/base/web/images/cloudinary_vertical_logo_for_white_bg.svg b/view/base/web/images/cloudinary_vertical_logo_for_white_bg.svg
deleted file mode 100644
index 2e4d2e02..00000000
--- a/view/base/web/images/cloudinary_vertical_logo_for_white_bg.svg
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From d8c224e2857e28b31db346f3336d102f1e5e0949 Mon Sep 17 00:00:00 2001
From: pini-girit
Date: Thu, 9 Sep 2021 11:22:25 +0300
Subject: [PATCH 03/11] v1.17.0:CLOUDINARY-209: Allow applying products-global
transformation
---
Controller/Adminhtml/Ajax/Free/Image.php | 2 +-
.../Source/Dropdown/FreeTransformBehavior.php | 22 +++++
Model/Configuration.php | 31 ++++++-
Plugin/Catalog/Block/Product/ImageFactory.php | 2 +-
.../Model/Product/Image/UrlBuilder.php | 2 +-
.../Product/Form/Modifier/Product.php | 19 +++--
etc/adminhtml/system.xml | 13 +++
etc/config.xml | 1 +
view/adminhtml/templates/config/free.phtml | 2 +-
view/adminhtml/web/js/cloudinary-free.js | 81 +++++++++++++++----
10 files changed, 142 insertions(+), 33 deletions(-)
create mode 100644 Model/Config/Source/Dropdown/FreeTransformBehavior.php
diff --git a/Controller/Adminhtml/Ajax/Free/Image.php b/Controller/Adminhtml/Ajax/Free/Image.php
index e2102821..2784a18d 100644
--- a/Controller/Adminhtml/Ajax/Free/Image.php
+++ b/Controller/Adminhtml/Ajax/Free/Image.php
@@ -76,7 +76,7 @@ public function execute()
*/
private function defaultTransformWithFreeTransform($freeTransform)
{
- $transformation = $this->configuration->getDefaultTransformation();
+ $transformation = $this->configuration->getDefaultTransformation(true);
if ($freeTransform) {
$transformation->withFreeform(Freeform::fromString($freeTransform));
diff --git a/Model/Config/Source/Dropdown/FreeTransformBehavior.php b/Model/Config/Source/Dropdown/FreeTransformBehavior.php
new file mode 100644
index 00000000..2ed10c1e
--- /dev/null
+++ b/Model/Config/Source/Dropdown/FreeTransformBehavior.php
@@ -0,0 +1,22 @@
+ 'add',
+ 'label' => 'Add',
+ ],
+ [
+ 'value' => 'override',
+ 'label' => 'Override',
+ ],
+ ];
+ }
+}
diff --git a/Model/Configuration.php b/Model/Configuration.php
index e5798956..174e005b 100644
--- a/Model/Configuration.php
+++ b/Model/Configuration.php
@@ -44,6 +44,8 @@ class Configuration implements ConfigurationInterface
const CONFIG_PATH_DEFAULT_FETCH_FORMAT = 'cloudinary/transformations/cloudinary_fetch_format';
const CONFIG_PATH_DEFAULT_IMAGE = 'cloudinary/transformations/cloudinary_default_image';
const CONFIG_PATH_GLOBAL_FREEFORM = 'cloudinary/transformations/cloudinary_free_transform_global';
+ const CONFIG_PATH_GLOBAL_FREEFORM_PRODUCTS = 'cloudinary/transformations/cloudinary_free_transform_global_products';
+ const CONFIG_PATH_GLOBAL_FREEFORM_PRODUCTS_BEHAVIOR = 'cloudinary/transformations/cloudinary_free_transform_global_products_behavior';
//= Lazyload
const XML_PATH_LAZYLOAD_ENABLED = 'cloudinary/lazyload/enabled';
@@ -231,15 +233,24 @@ public function getCredentials()
}
/**
+ * @param bool $isProduct
* @return Transformation
*/
- public function getDefaultTransformation()
+ public function getDefaultTransformation($isProduct = false)
{
+ if ($isProduct && ($globalFreeform = $this->getDefaultGlobalFreeformProducts())) {
+ if ($this->getDefaultGlobalFreeformProductsBehavior() === 'add') {
+ $globalFreeform = $this->getDefaultGlobalFreeform() . ',' . $globalFreeform;
+ }
+ } else {
+ $globalFreeform = $this->getDefaultGlobalFreeform();
+ }
+
return Transformation::builder()
->withGravity(Gravity::fromString($this->getDefaultGravity()))
->withQuality(Quality::fromString($this->getImageQuality()))
->withFetchFormat(FetchFormat::fromString($this->getFetchFormat()))
- ->withFreeform(Freeform::fromString($this->getDefaultGlobalFreeform()))
+ ->withFreeform(Freeform::fromString($globalFreeform))
->withDpr(Dpr::fromString($this->getImageDpr()))
->withDefaultImage(DefaultImage::fromString($this->getCloudinaryDefaultImage()));
}
@@ -252,6 +263,22 @@ private function getDefaultGlobalFreeform()
return (string) $this->configReader->getValue(self::CONFIG_PATH_GLOBAL_FREEFORM);
}
+ /**
+ * @return string
+ */
+ private function getDefaultGlobalFreeformProducts()
+ {
+ return (string) $this->configReader->getValue(self::CONFIG_PATH_GLOBAL_FREEFORM_PRODUCTS);
+ }
+
+ /**
+ * @return string
+ */
+ private function getDefaultGlobalFreeformProductsBehavior()
+ {
+ return (string) $this->configReader->getValue(self::CONFIG_PATH_GLOBAL_FREEFORM_PRODUCTS_BEHAVIOR);
+ }
+
/**
* @return boolean
*/
diff --git a/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php
index 1feb1bbe..b665cedf 100644
--- a/Plugin/Catalog/Block/Product/ImageFactory.php
+++ b/Plugin/Catalog/Block/Product/ImageFactory.php
@@ -216,7 +216,7 @@ function () use ($imageBlock) {
private function createTransformation(array $imageMiscParams)
{
$dimensions = $this->getDimensions($imageMiscParams);
- $transform = $this->configuration->getDefaultTransformation()->withDimensions($dimensions);
+ $transform = $this->configuration->getDefaultTransformation(true)->withDimensions($dimensions);
if (isset($imageMiscParams['keep_frame'])) {
$this->keepFrame = ($imageMiscParams['keep_frame'] === 'frame') ? true : false;
diff --git a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
index 2d38ab4c..26e1d10d 100644
--- a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
+++ b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
@@ -179,7 +179,7 @@ private function createTransformation(array $imageMiscParams)
$imageMiscParams['image_height'] = (isset($imageMiscParams['image_height'])) ? $imageMiscParams['image_height'] : null;
$imageMiscParams['image_width'] = (isset($imageMiscParams['image_width'])) ? $imageMiscParams['image_width'] : null;
$dimensions = $this->dimensions ?: Dimensions::fromWidthAndHeight($imageMiscParams['image_width'], $imageMiscParams['image_height']);
- $transform = $this->configuration->getDefaultTransformation()->withDimensions($dimensions);
+ $transform = $this->configuration->getDefaultTransformation(true)->withDimensions($dimensions);
if (isset($imageMiscParams['keep_frame'])) {
$this->keepFrame = ($imageMiscParams['keep_frame'] === 'frame') ? true : false;
diff --git a/Ui/DataProvider/Product/Form/Modifier/Product.php b/Ui/DataProvider/Product/Form/Modifier/Product.php
index ec2d268e..71b5943c 100644
--- a/Ui/DataProvider/Product/Form/Modifier/Product.php
+++ b/Ui/DataProvider/Product/Form/Modifier/Product.php
@@ -2,17 +2,17 @@
namespace Cloudinary\Cloudinary\Ui\DataProvider\Product\Form\Modifier;
-use Cloudinary\Cloudinary\Core\Image;
use Cloudinary\Cloudinary\Core\CloudinaryImageProvider;
use Cloudinary\Cloudinary\Core\ConfigurationInterface;
+use Cloudinary\Cloudinary\Core\Image;
use Cloudinary\Cloudinary\Core\Image\Transformation;
use Cloudinary\Cloudinary\Core\Image\Transformation\Freeform;
-use Magento\Catalog\Model\Locator\LocatorInterface;
-use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
-use Magento\Ui\Component\Form;
use Cloudinary\Cloudinary\Model\TransformationFactory;
+use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Model\Product\Gallery\Entry;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Framework\UrlInterface;
+use Magento\Ui\Component\Form;
class Product extends AbstractModifier
{
@@ -102,11 +102,10 @@ public function modifyMeta(array $meta)
'collapsible' => true,
'opened' => false,
'componentType' => Form\Fieldset::NAME,
- 'sortOrder' =>
- $this->getNextGroupSortOrder(
- $meta,
- static::GROUP_CONTENT,
- static::SORT_ORDER
+ 'sortOrder' => $this->getNextGroupSortOrder(
+ $meta,
+ static::GROUP_CONTENT,
+ static::SORT_ORDER
),
],
],
@@ -223,7 +222,7 @@ private function injectImageUrls(array $images)
*/
private function defaultTransformWithFreeTransform($freeTransform)
{
- $transformation = $this->configuration->getDefaultTransformation();
+ $transformation = $this->configuration->getDefaultTransformation(true);
if ($freeTransform) {
$transformation->withFreeform(Freeform::fromString($freeTransform));
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index af50f581..d61150a7 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -84,7 +84,20 @@
Global Custom Transformation
Custom transformations will be added to the default image transformations settings chosen above. For information about the full range of transforms available see the Cloudinary documentation . You may need to clear or rebuild the Magento block and full page caches to see the changes in the front end.]]>
Cloudinary\Cloudinary\Model\Config\Backend\Free
+ cloudinary/transformations/cloudinary_free_transform_global
+
+
+ Products Custom Transformation
+ for products only.
+ *Set the behavior of this field on the dropdown below.]]>
+ Cloudinary\Cloudinary\Model\Config\Backend\Free
+ cloudinary/transformations/cloudinary_free_transform_global_products
+
+
+ Products Custom Transformation Behavior
+ Cloudinary\Cloudinary\Model\Config\Source\Dropdown\FreeTransformBehavior
Cloudinary\Cloudinary\Block\Adminhtml\Form\Field\Free
+ cloudinary/transformations/cloudinary_free_transform_global_products_behavior
diff --git a/etc/config.xml b/etc/config.xml
index 2a6615ec..14c5437b 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -7,6 +7,7 @@
1
auto
2.0
+ add
1
diff --git a/view/adminhtml/templates/config/free.phtml b/view/adminhtml/templates/config/free.phtml
index 95b8ef07..82b49cc6 100644
--- a/view/adminhtml/templates/config/free.phtml
+++ b/view/adminhtml/templates/config/free.phtml
@@ -18,5 +18,5 @@
", "ajaxKey": "= $this->getFormKey() ?>"}}'>
+ data-mage-init='{"cloudinaryFreeTransform":{"previewButtonId": "#cloudinary_free_transform_preview_button", "transformInputFieldId": "#cloudinary_transformations_cloudinary_free_transform_global", "transformInputProductsFieldId": "#cloudinary_transformations_cloudinary_free_transform_global_products", "transformInputProductsBehaviorFieldId": "#cloudinary_transformations_cloudinary_free_transform_global_products_behavior", "ajaxUrl": "= $this->getUrl('cloudinary/ajax_free/sample') ?>", "ajaxKey": "= $this->getFormKey() ?>"}}'>
diff --git a/view/adminhtml/web/js/cloudinary-free.js b/view/adminhtml/web/js/cloudinary-free.js
index 374c9b83..82077e00 100644
--- a/view/adminhtml/web/js/cloudinary-free.js
+++ b/view/adminhtml/web/js/cloudinary-free.js
@@ -9,46 +9,58 @@ define(
'cloudinary.cloudinaryFreeTransform', {
currentTransform: '',
+ currentTransformProducts: '',
getTransformText: function() {
- return $(this.options.transformInputFieldId).val();
+ return $(this.options.transformInputFieldId).val() || '';
},
- getImageHtml: function(src) {
- var id = 'cloudinary_custom_transform_preview_image',
- style = 'width: auto; height: auto; max-width: 500px; max-height: 500px; min-height: 50px;',
+ getTransformProductsText: function() {
+ return $(this.options.transformInputProductsFieldId).val() || '';
+ },
+
+ getTransformBehavior: function() {
+ return $(this.options.transformInputProductsBehaviorFieldId).val();
+ },
+
+ getImageHtml: function(src, header) {
+ if (!src) {
+ return '';
+ }
+ var cls = 'cloudinary_custom_transform_preview_image',
+ style = 'width: auto; height: auto; max-width: 350px; max-height: 350px; min-height: 50px;',
+ header = header || '',
footer = 'Image size restricted for viewing purposes
';
- return ' ' + footer;
+ return header + ' ' + footer;
},
getErrorHtml: function(message) {
return '';
},
- updatePreviewImage: function(url) {
- var $image = $('#cloudinary_custom_transform_preview_image');
-
- if (!$image.length) {
- $('#cloudinary_custom_transform_preview').html(this.getImageHtml(url));
- } else {
- $image.attr('src', url);
- }
+ updatePreviewImage: function(url, url2) {
+ $('#cloudinary_custom_transform_preview').html(
+ this.getImageHtml(url, 'Global Custom Transformation Preview
') +
+ this.getImageHtml(url2, 'Products Custom Transformation Preview
')
+ );
},
updatePreview: function() {
- var self = this;
+ var self = this,
+ transformations_string = "";
if (!self.isPreviewActive()) {
return;
}
self.currentTransform = self.getTransformText();
+ self.currentTransformProducts = self.getTransformProductsText();
self.setPreviewActiveState(false);
$.ajax({
url: this.options.ajaxUrl,
data: {
- free: self.getTransformText(),
+ free: self.currentTransform,
form_key: self.options.ajaxKey
},
type: 'post',
@@ -56,7 +68,33 @@ define(
showLoader: true
}).done(
function(response) {
- self.updatePreviewImage(response.url);
+ if ((transformations_string = self.currentTransformProducts)) {
+ if (self.getTransformBehavior() === 'add') {
+ transformations_string = self.currentTransform + ',' + transformations_string;
+ }
+ var globalResURL = response.url;
+ $.ajax({
+ url: self.options.ajaxUrl,
+ data: {
+ free: transformations_string,
+ form_key: self.options.ajaxKey
+ },
+ type: 'post',
+ dataType: 'json',
+ showLoader: true
+ }).done(
+ function(response) {
+ self.updatePreviewImage(globalResURL, response.url);
+ }
+ ).fail(
+ function(result) {
+ $('#cloudinary_custom_transform_preview').html(self.getErrorHtml(result.responseJSON.error));
+ }
+ );
+ } else {
+ return self.updatePreviewImage(response.url);
+ transformations_string = self.getTransformText();
+ }
}
).fail(
function(result) {
@@ -66,7 +104,10 @@ define(
},
setPreviewActiveState: function(state) {
- if (state && (this.currentTransform !== this.getTransformText())) {
+ if (
+ state &&
+ (this.currentTransform !== this.getTransformText() || self.currentTransformProducts !== this.getTransformProductsText())
+ ) {
$(this.options.previewButtonId).removeClass('disabled');
} else {
$(this.options.previewButtonId).addClass('disabled');
@@ -92,6 +133,12 @@ define(
self.setPreviewActiveState(true);
}
);
+ $(this.options.transformInputProductsFieldId).on(
+ 'change keydown paste input',
+ function() {
+ self.setPreviewActiveState(true);
+ }
+ );
}
}
From 9c911244222c7940682b83c1c0a7182c5768a92d Mon Sep 17 00:00:00 2001
From: pini-girit
Date: Thu, 9 Sep 2021 11:22:25 +0300
Subject: [PATCH 04/11] v1.17.0:CLOUDINARY-209: Allow applying products-global
transformation
---
view/adminhtml/web/js/cloudinary-free.js | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/view/adminhtml/web/js/cloudinary-free.js b/view/adminhtml/web/js/cloudinary-free.js
index 82077e00..e98ed72a 100644
--- a/view/adminhtml/web/js/cloudinary-free.js
+++ b/view/adminhtml/web/js/cloudinary-free.js
@@ -10,6 +10,7 @@ define(
currentTransform: '',
currentTransformProducts: '',
+ currentTransformBehavior: '',
getTransformText: function() {
return $(this.options.transformInputFieldId).val() || '';
@@ -55,6 +56,7 @@ define(
self.currentTransform = self.getTransformText();
self.currentTransformProducts = self.getTransformProductsText();
+ self.currentTransformBehavior = self.getTransformBehavior();
self.setPreviewActiveState(false);
$.ajax({
@@ -69,7 +71,7 @@ define(
}).done(
function(response) {
if ((transformations_string = self.currentTransformProducts)) {
- if (self.getTransformBehavior() === 'add') {
+ if (self.currentTransformBehavior === 'add') {
transformations_string = self.currentTransform + ',' + transformations_string;
}
var globalResURL = response.url;
@@ -106,7 +108,11 @@ define(
setPreviewActiveState: function(state) {
if (
state &&
- (this.currentTransform !== this.getTransformText() || self.currentTransformProducts !== this.getTransformProductsText())
+ (
+ this.currentTransform !== this.getTransformText() ||
+ this.currentTransformProducts !== this.getTransformProductsText() ||
+ (this.getTransformProductsText() && this.currentTransformBehavior !== this.getTransformBehavior())
+ )
) {
$(this.options.previewButtonId).removeClass('disabled');
} else {
@@ -139,6 +145,12 @@ define(
self.setPreviewActiveState(true);
}
);
+ $(this.options.transformInputProductsBehaviorFieldId).on(
+ 'change',
+ function() {
+ self.setPreviewActiveState(true);
+ }
+ );
}
}
From efe12c44593c90adf4ee45ad0c6630171f028f80 Mon Sep 17 00:00:00 2001
From: pniel-cohen
Date: Mon, 4 Oct 2021 11:18:39 +0300
Subject: [PATCH 05/11] CLOUDINARY-347: Fix for Transformations keep_frame is
not working (GH issue #105)
---
Plugin/Catalog/Block/Product/ImageFactory.php | 2 +-
Plugin/Catalog/Model/Product/Image/UrlBuilder.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php
index b665cedf..657f3642 100644
--- a/Plugin/Catalog/Block/Product/ImageFactory.php
+++ b/Plugin/Catalog/Block/Product/ImageFactory.php
@@ -219,7 +219,7 @@ private function createTransformation(array $imageMiscParams)
$transform = $this->configuration->getDefaultTransformation(true)->withDimensions($dimensions);
if (isset($imageMiscParams['keep_frame'])) {
- $this->keepFrame = ($imageMiscParams['keep_frame'] === 'frame') ? true : false;
+ $this->keepFrame = (bool) $imageMiscParams['keep_frame'];
}
if ($this->keepFrame) {
diff --git a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
index 26e1d10d..60268a0a 100644
--- a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
+++ b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
@@ -182,7 +182,7 @@ private function createTransformation(array $imageMiscParams)
$transform = $this->configuration->getDefaultTransformation(true)->withDimensions($dimensions);
if (isset($imageMiscParams['keep_frame'])) {
- $this->keepFrame = ($imageMiscParams['keep_frame'] === 'frame') ? true : false;
+ $this->keepFrame = (bool) $imageMiscParams['keep_frame'];
}
if ($this->keepFrame) {
From 0dccae7ba0666c646dbd400335bf609a5e462313 Mon Sep 17 00:00:00 2001
From: Maya Shavin
Date: Wed, 8 Dec 2021 10:53:32 +0200
Subject: [PATCH 06/11] add: GraphQL support for query Cld images
---
.../ProductAttributeCldResolver.php | 42 +++++++++++++++++++
etc/schema.graphqls | 12 ++++++
2 files changed, 54 insertions(+)
create mode 100644 Model/GraphQLResolver/ProductAttributeCldResolver.php
create mode 100644 etc/schema.graphqls
diff --git a/Model/GraphQLResolver/ProductAttributeCldResolver.php b/Model/GraphQLResolver/ProductAttributeCldResolver.php
new file mode 100644
index 00000000..5520e6f1
--- /dev/null
+++ b/Model/GraphQLResolver/ProductAttributeCldResolver.php
@@ -0,0 +1,42 @@
+productGalleryManagement = $productGalleryManagement;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
+ {
+ $productId = $value['sku'];
+ $productMediaStr = $this->productGalleryManagement->getProductMedia($productId);
+ $jsonDecoder = new \Magento\Framework\Serialize\Serializer\Json();
+ $productMedia = $jsonDecoder->unserialize($productMediaStr);
+ return $productMedia['data'];
+ }
+ }
\ No newline at end of file
diff --git a/etc/schema.graphqls b/etc/schema.graphqls
new file mode 100644
index 00000000..8d2e385b
--- /dev/null
+++ b/etc/schema.graphqls
@@ -0,0 +1,12 @@
+type CloudinaryData {
+ image: String
+ small_image: String
+ thumbnail: String
+ media_gallery: [String]
+}
+
+interface ProductInterface {
+ cld_data: CloudinaryData
+ @resolver(class: "\\Cloudinary\\Cloudinary\\Model\\GraphQLResolver\\ProductAttributeCldResolver")
+ @doc(description: "Cloudinary urls generated for product images")
+}
\ No newline at end of file
From 9478bedb08964f0c4e05629358e36cd4062adbf5 Mon Sep 17 00:00:00 2001
From: pniel-cohen
Date: Tue, 7 Dec 2021 09:40:10 +0200
Subject: [PATCH 07/11] CLOUDINARY-332: Added analytics query param to all CLD
URLs
---
Core/CloudinaryImageProvider.php | 2 +-
Model/Configuration.php | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Core/CloudinaryImageProvider.php b/Core/CloudinaryImageProvider.php
index 218a8838..f8f6d544 100644
--- a/Core/CloudinaryImageProvider.php
+++ b/Core/CloudinaryImageProvider.php
@@ -134,7 +134,7 @@ public function retrieveTransformed(Image $image, Transformation $transformation
'sign_url' => $this->configuration->getUseSignedUrls(),
'version' => 1
]
- );
+ ) . '?_i=AB';
if (!$this->configuration->isEnabledProductGallery()) {
//Handle with use-root-path if necessary:
diff --git a/Model/Configuration.php b/Model/Configuration.php
index 174e005b..b0654441 100644
--- a/Model/Configuration.php
+++ b/Model/Configuration.php
@@ -602,11 +602,15 @@ public function getMagentoPlatformVersion()
*/
public function parseCloudinaryUrl($url, $publicId = null)
{
+ $parsedUrlParts = $this->mbParseUrl($url);
+ $url = preg_replace('/\?.*/', '', $url);
+
$parsed = [
"orig_url" => $url,
- "scheme" => null,
- "host" => null,
- "path" => null,
+ "scheme" => isset($parsedUrlParts["scheme"]) ? $parsedUrlParts["scheme"] : null,
+ "host" => isset($parsedUrlParts["host"]) ? $parsedUrlParts["host"] : null,
+ "path" => isset($parsedUrlParts["path"]) ? $parsedUrlParts["path"] : null,
+ "query" => isset($parsedUrlParts["query"]) ? $parsedUrlParts["query"] : null,
"extension" => \pathinfo($url, PATHINFO_EXTENSION),
"type" => null,
"cloudName" => null,
@@ -620,10 +624,6 @@ public function parseCloudinaryUrl($url, $publicId = null)
"thumbnail_url" => null,
];
- $parsed["scheme"] = $this->mbParseUrl($url, PHP_URL_SCHEME);
- $parsed["host"] = $this->mbParseUrl($url, PHP_URL_HOST);
- $parsed["path"] = $this->mbParseUrl($url, PHP_URL_PATH);
-
$_url = ltrim($parsed["path"], '/');
$_url = preg_replace('/\.[^.]+$/', '', $_url);
From 6f54a7e130aa3a1a8123d42b28b4faafd1bc3ad5 Mon Sep 17 00:00:00 2001
From: pniel-cohen
Date: Thu, 9 Dec 2021 09:25:05 +0200
Subject: [PATCH 08/11] MAG-431,CLOUDINARY-356: Added a note to the
auto-upload-mapping configuration
---
etc/adminhtml/system.xml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index d61150a7..7ff03b4d 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -42,7 +42,10 @@
Enable auto-upload
- Automatically upload your existing Magento images to your Cloudinary account when an image is requested by a user. Once enabled, click the button below to map your Magento media directory to your Cloudinary account.
+ Automatically upload your existing Magento images to your Cloudinary account when an image is requested by a user. Once enabled, click the button below to map your Magento media directory to your Cloudinary account.
+ Note: Disabling auto upload mapping from Magento will not remove the configuration from Cloudinary. To completely disable your auto upload mapping, navigate to your Cloudinary Upload settings and clear the Auto upload mapping that corresponds to your Magento URLs.
]]>
+
Magento\Config\Model\Config\Source\Yesno
From 9a877efd6de813d601ceb656e4e5cf68fa2d8944 Mon Sep 17 00:00:00 2001
From: pniel-cohen
Date: Thu, 9 Dec 2021 16:46:40 +0200
Subject: [PATCH 09/11] MAG-773,CLOUDINARY-358: Fixed video URL validation on
page-builder to support Magento v2.4^
---
...uilder_base_form_with_background_video.xml | 18 +++++++++++
.../ui_component/pagebuilder_video_form.xml | 14 ++++----
.../js/form/element/validator-rules-mixin.js | 32 +++++++++++++++++--
3 files changed, 53 insertions(+), 11 deletions(-)
create mode 100644 view/adminhtml/ui_component/pagebuilder_base_form_with_background_video.xml
diff --git a/view/adminhtml/ui_component/pagebuilder_base_form_with_background_video.xml b/view/adminhtml/ui_component/pagebuilder_base_form_with_background_video.xml
new file mode 100644
index 00000000..2b74c1a5
--- /dev/null
+++ b/view/adminhtml/ui_component/pagebuilder_base_form_with_background_video.xml
@@ -0,0 +1,18 @@
+
+
+
diff --git a/view/adminhtml/ui_component/pagebuilder_video_form.xml b/view/adminhtml/ui_component/pagebuilder_video_form.xml
index c64340f9..81ef3934 100644
--- a/view/adminhtml/ui_component/pagebuilder_video_form.xml
+++ b/view/adminhtml/ui_component/pagebuilder_video_form.xml
@@ -6,15 +6,13 @@
*/
-->