diff --git a/Block/Tag.php b/Block/Tag.php index ec03f9d..9bd6401 100644 --- a/Block/Tag.php +++ b/Block/Tag.php @@ -71,6 +71,9 @@ public function getConfigToString(): string $config .= 'processQueryString: function (props) ' . $this->config->getCustomFunction() . ', '; } $config .= 'devicePixelRatioList: ' . $this->formatRatioList($this->config->getDevicePixelRatio()) . ', '; + if ($this->config->isOrgIfSml()) { + $config .= 'params: {org_if_sml: 1}, '; + } $config .= 'token:\'' . $this->config->getToken() . '\' '; return $config; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 761206c..39e8fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [2.0.3] - 2022-04-27 + +* Support Multiple store views(websites) +* Add config to prevent image resize when set Device Pixel Max Ratio equal to 2 + ## [2.0.2] - 2022-04-08 * Add Fotorama Compatibility Mode option diff --git a/Helper/Config.php b/Helper/Config.php index b7f9682..e6b76d9 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -36,13 +36,14 @@ class Config extends AbstractHelper const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7 = 'scaleflex_cloudimage/advanced/remove_v7'; const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY = 'scaleflex_cloudimage/advanced/fortorama_compatibility'; const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO = 'scaleflex_cloudimage/advanced/devicepixelratio'; + const XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_ORG_IF_SML = 'scaleflex_cloudimage/advanced/orgifsml'; /** * @return bool */ public function getApiUrl() { - return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_CDN_API_URL); + return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_CDN_API_URL, ScopeInterface::SCOPE_STORE); } /** @@ -54,7 +55,7 @@ public function getToken() { return $this->scopeConfig->getValue( self::XML_PATH_SCALEFLEX_CLOUDIMAGE_GENERAL_TOKEN, - ScopeInterface::SCOPE_WEBSITE + ScopeInterface::SCOPE_STORE ); } @@ -103,7 +104,8 @@ public function getCustomFunction() public function getImageQuality() { $imageQuality = (int)$this->scopeConfig->getValue( - self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_IMAGE_QUALITY + self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_IMAGE_QUALITY, + ScopeInterface::SCOPE_STORE ); if ($imageQuality > 0 && $imageQuality <= 100) { return $imageQuality; @@ -118,7 +120,7 @@ public function getImageQuality() */ public function getLibraryOptions() { - $options = $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_LIBRARY_OPTIONS); + $options = $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_LIBRARY_OPTIONS, ScopeInterface::SCOPE_STORE); if (is_string($options) && strlen(trim($options)) > 0) { return trim($options); } @@ -166,7 +168,7 @@ public function isDoNotReplaceUrl() { return (bool)$this->scopeConfig->getValue( self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_DO_NOT_REPLACE_URL, - ScopeInterface::SCOPE_WEBSITE + ScopeInterface::SCOPE_STORE ); } @@ -177,7 +179,7 @@ public function isIgnoreNodeImgSize() { return (bool)$this->scopeConfig->getValue( self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_IGNORE_NODE_IMG_SIZE, - ScopeInterface::SCOPE_WEBSITE + ScopeInterface::SCOPE_STORE ); } @@ -188,7 +190,18 @@ public function isIgnoreStyleImgSize() { return (bool)$this->scopeConfig->getValue( self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_IGNORE_STYLE_IMG_SIZE, - ScopeInterface::SCOPE_WEBSITE + ScopeInterface::SCOPE_STORE + ); + } + + /** + * @return bool + */ + public function isOrgIfSml() + { + return (bool)$this->scopeConfig->getValue( + self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_ORG_IF_SML, + ScopeInterface::SCOPE_STORE ); } @@ -201,7 +214,7 @@ public function isLazyLoading() { return (bool)$this->scopeConfig->getValue( self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_LAZY_LOADING, - ScopeInterface::SCOPE_WEBSITE + ScopeInterface::SCOPE_STORE ); } @@ -212,7 +225,7 @@ public function isLazyLoading() */ public function isIgnoreSvg() { - return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_PROCESS_SVG); + return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_PROCESS_SVG, ScopeInterface::SCOPE_STORE); } @@ -223,7 +236,7 @@ public function isIgnoreSvg() */ public function getDevicePixelRatio() { - return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO); + return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO, ScopeInterface::SCOPE_STORE); } /** @@ -233,13 +246,13 @@ public function getDevicePixelRatio() */ public function isRemoveV7() { - return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7); + return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7, ScopeInterface::SCOPE_STORE); } /** * @return bool */ public function isFotoramaCompatibility() { - return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY); + return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY, ScopeInterface::SCOPE_STORE); } } diff --git a/README.md b/README.md index 88b9a6d..6d92cb6 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Once the steps listed above are completed enter your Cloudimage token into the S Stores > Configuration > Cloudimage By Scaleflex > Cloudimage ``` -![Scaleflex Cloudimage Plugin Configuration](doc/images/cloudimage_plugin_config.png "Scaleflex Cloudimage Configuration Page") +![Scaleflex Cloudimage Plugin Configuration](doc/images/cloudimage_plugin_config_2.0.3.png "Scaleflex Cloudimage Configuration Page") Expand the `General` section and activate the module by selecting `Yes` in the `Scaleflex Cloudimage Active` dropdown. Enter your Cloudimage token and configure the Options. @@ -72,6 +72,8 @@ After saving the configuration, you will be asked to flush your Magento cache. ## Options +**(New) Support multiple websites and store views, now you can have difference token for each website.** + Following options are available: **Use origin URL:** If enabled, the module will only add query parameters to the image source URL without prefixing it with `{token}.cloudimg.io`. This is required if you use a dedicated subdomain for delivering your images (media) in Magento. You will need to complete the steps for enabling a custom CNAME in Cloudimage documented here. @@ -96,9 +98,11 @@ This setting is for advanced users only and allows to inject a custom JS functio **Ignore SVG images**: If enabled, all SVG images will be skipped from acceleration as anyway vector images will not be compressed. -**(new) Fotorama Compatibility Mode**: Fotorama compatibility mode, default no +**Fotorama Compatibility Mode**: Fotorama compatibility mode, default no + +**Maximum "Pixel ratio"**: List of supported device pixel ratios, default is 2, eg: 2 for Retina devices -**(new) Maximum "Pixel ratio"**: List of supported device pixel ratios, default is 2, eg: 2 for Retina devices +**(New)Prevent Image Resize**: If you set Maximum "Pixel ratio" equal to 2, but some of your assets does not have min retina size(at least 2560x960), please enable this to prevent image resized **Custom Library Options**: Those optional parameters will be added to the request for each URL going through the Cloudimage acceleration infrastructure. It can allow you to force image formats, apply automatic transformations or watermarking, and might be used for troubleshooting purposes. (for advanced users only, please refer to the official [Cloudimage documentation here](https://docs/cloudimage.io) for the list of possible parameters) diff --git a/composer.json b/composer.json index 45ab8d7..0371337 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "ext-libxml": "*" }, "type": "magento2-module", - "version": "2.0.2", + "version": "2.0.3", "license": "BSD-3-Clause", "authors": [ { diff --git a/doc/images/cloudimage_plugin_config.png b/doc/images/cloudimage_plugin_config.png index 4e8385c..5ea108a 100644 Binary files a/doc/images/cloudimage_plugin_config.png and b/doc/images/cloudimage_plugin_config.png differ diff --git a/doc/images/cloudimage_plugin_config_2.0.3.png b/doc/images/cloudimage_plugin_config_2.0.3.png new file mode 100644 index 0000000..49a954a Binary files /dev/null and b/doc/images/cloudimage_plugin_config_2.0.3.png differ diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 061fcac..0237d83 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -15,72 +15,72 @@ -
+
cloudimage Scaleflex_Cloudimage::config - + - + Magento\Config\Model\Config\Source\Yesno - + 1 - + - + Magento\Config\Model\Config\Source\Yesno - + Magento\Config\Model\Config\Source\Yesno - + Magento\Config\Model\Config\Source\Yesno - + Magento\Config\Model\Config\Source\Yesno - + - + Magento\Config\Model\Config\Source\Yesno - + 1 - + Scaleflex\Cloudimage\Model\Config\Source\ImageQuality - + Magento\Config\Model\Config\Source\Yesno - + Magento\Config\Model\Config\Source\Yesno @@ -90,11 +90,16 @@ Scaleflex\Cloudimage\Model\Config\Source\PixelRatio - + + + Magento\Config\Model\Config\Source\Yesno + + + - + Magento\Config\Model\Config\Source\Yesno diff --git a/etc/config.xml b/etc/config.xml index a317728..d46eae1 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -9,9 +9,11 @@ 90 - 1 - 0 + 0 + 1 2 + 1 + 1 diff --git a/etc/module.xml b/etc/module.xml index 8a4fbbc..41a8b64 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ - +