From e2eddc00ea7368beb871046ffbf1b09b5bc378c5 Mon Sep 17 00:00:00 2001 From: pini-girit Date: Thu, 14 Feb 2019 17:12:10 +0200 Subject: [PATCH] CLOUDINARY-95: Bypassed ImageFactory plugin as a workaround for Magento versions prior to 2.3 --- Model/Configuration.php | 2 +- Plugin/Catalog/Block/Product/ImageFactory.php | 12 ++++++------ composer.json | 2 +- etc/module.xml | 2 +- marketplace.composer.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Model/Configuration.php b/Model/Configuration.php index 1d18078..8372e1c 100644 --- a/Model/Configuration.php +++ b/Model/Configuration.php @@ -159,7 +159,7 @@ public function getCdnSubdomainStatus() */ public function getUserPlatform() { - return sprintf(self::USER_PLATFORM_TEMPLATE, '1.7.4', '2.0.0'); + return sprintf(self::USER_PLATFORM_TEMPLATE, '1.7.5', '2.0.0'); } /** diff --git a/Plugin/Catalog/Block/Product/ImageFactory.php b/Plugin/Catalog/Block/Product/ImageFactory.php index 15f197e..52d814e 100644 --- a/Plugin/Catalog/Block/Product/ImageFactory.php +++ b/Plugin/Catalog/Block/Product/ImageFactory.php @@ -112,21 +112,21 @@ public function __construct( * @param array|null $attributes * @return ImageBlock */ - public function aroundCreate(CatalogImageFactory $catalogImageFactory, callable $proceed, Product $product, string $imageId, array $attributes = null) + public function aroundCreate(CatalogImageFactory $catalogImageFactory, callable $proceed, $product = null, $imageId = null, $attributes = null) { - $imageBlock = $proceed($product, $imageId, $attributes); + $imageBlock = call_user_func_array($proceed, array_slice(func_get_args(), 2)); if (!$this->configuration->isEnabled()) { return $imageBlock; } - if (class_exists('\Magento\Catalog\Model\Product\Image\ParamsBuilder')) { - $this->imageParamsBuilder = $this->objectManager->get('\Magento\Catalog\Model\Product\Image\ParamsBuilder'); - } else { - //Skip on Magento versions prior to 2.3 + //Skip on Magento versions prior to 2.3 + if (is_array($product) || !class_exists('\Magento\Catalog\Model\Product\Image\ParamsBuilder')) { return $imageBlock; } + $this->imageParamsBuilder = $this->objectManager->get('\Magento\Catalog\Model\Product\Image\ParamsBuilder'); + try { if (strpos($imageBlock->getImageUrl(), $this->configuration->getMediaBaseUrl() . 'catalog/product') === 0) { $viewImageConfig = $this->presentationConfig->getViewConfig()->getMediaAttributes( diff --git a/composer.json b/composer.json index 41d9be3..627b2a4 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.7.4", + "version": "1.7.5", "license": "MIT", "require": { "cloudinary/cloudinary_php": "*" diff --git a/etc/module.xml b/etc/module.xml index 1454e47..9e78439 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/marketplace.composer.json b/marketplace.composer.json index d747db2..ca38819 100644 --- a/marketplace.composer.json +++ b/marketplace.composer.json @@ -1,7 +1,7 @@ { "name": "cloudinary/cloudinary", "type": "magento2-module", - "version": "1.7.4", + "version": "1.7.5", "description": "Cloudinary Magento 2 Integration.", "license": "MIT", "require": {