diff --git a/Controller/Adminhtml/Ajax/Free/Image.php b/Controller/Adminhtml/Ajax/Free/Image.php
index e210282..2784a18 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/Core/CloudinaryImageProvider.php b/Core/CloudinaryImageProvider.php
index 218a883..f8f6d54 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/Helper/ProductGalleryHelper.php b/Helper/ProductGalleryHelper.php
index 9e9c309..8e3103c 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/Model/Config/Source/Dropdown/FreeTransformBehavior.php b/Model/Config/Source/Dropdown/FreeTransformBehavior.php
new file mode 100644
index 0000000..2ed10c1
--- /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 e579895..b065444 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
*/
@@ -575,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,
@@ -593,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);
diff --git a/Model/GraphQLResolver/ProductAttributeCldResolver.php b/Model/GraphQLResolver/ProductAttributeCldResolver.php
new file mode 100644
index 0000000..5520e6f
--- /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/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php
index 1feb1bb..657f364 100644
--- a/Plugin/Catalog/Block/Product/ImageFactory.php
+++ b/Plugin/Catalog/Block/Product/ImageFactory.php
@@ -216,10 +216,10 @@ 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;
+ $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 2d38ab4..60268a0 100644
--- a/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
+++ b/Plugin/Catalog/Model/Product/Image/UrlBuilder.php
@@ -179,10 +179,10 @@ 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;
+ $this->keepFrame = (bool) $imageMiscParams['keep_frame'];
}
if ($this->keepFrame) {
diff --git a/Ui/DataProvider/Product/Form/Modifier/Product.php b/Ui/DataProvider/Product/Form/Modifier/Product.php
index ec2d268..71b5943 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/composer.json b/composer.json
index cb537ae..4b1b87b 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/adminhtml/system.xml b/etc/adminhtml/system.xml
index af50f58..7ff03b4 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -42,7 +42,10 @@
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.
]]> +