Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Block/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 25 additions & 12 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -54,7 +55,7 @@ public function getToken()
{
return $this->scopeConfig->getValue(
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_GENERAL_TOKEN,
ScopeInterface::SCOPE_WEBSITE
ScopeInterface::SCOPE_STORE
);
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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
);
}

Expand All @@ -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
);
}

Expand All @@ -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
);
}

Expand All @@ -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
);
}

Expand All @@ -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);
}


Expand All @@ -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);
}

/**
Expand All @@ -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);
}
}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ 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.

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.
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ext-libxml": "*"
},
"type": "magento2-module",
"version": "2.0.2",
"version": "2.0.3",
"license": "BSD-3-Clause",
"authors": [
{
Expand Down
Binary file modified doc/images/cloudimage_plugin_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/cloudimage_plugin_config_2.0.3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 22 additions & 17 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,72 @@
<tab id="cloudimage" translate="label" sortOrder="200">
<label>Cloudimage by Scaleflex</label>
</tab>
<section id="scaleflex_cloudimage" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<section id="scaleflex_cloudimage" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Cloudimage</label>
<tab>cloudimage</tab>
<resource>Scaleflex_Cloudimage::config</resource>
<group id="general" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<group id="general" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Scaleflex Cloudimage Active</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[]]></comment>
</field>
<field id="token" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="token" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Token</label>
<depends>
<field id="active">1</field>
</depends>
</field>
</group>
<group id="options" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<group id="options" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Options</label>
<field id="do_not_replace_url" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="do_not_replace_url" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Use origin URL</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[If enabled, the plugin will only add query parameters to the image source URL, avoiding double CDNization in some cases, like if you have aliases configured.]]></comment>
</field>
<field id="ignore_node_img_size" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="ignore_node_img_size" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Ignore Image Size Node</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Can be useful for improving compatibility with some themes.]]></comment>
</field>
<field id="ignore_style_img_size" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="ignore_style_img_size" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Ignore Image Size Style</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Can be useful for improving compatibility with some themes.]]></comment>
</field>
<field id="lazy_loading" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="lazy_loading" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Lazy Loading</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[If enabled, only images close to the current viewpoint will be loaded.]]></comment>
</field>
</group>
<group id="advanced" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
<group id="advanced" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Advanced Configuration</label>
<field id="custom_function_active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="custom_function_active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Inject Custom js function</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Can be used to inject special js function depending on your theme.]]></comment>
</field>
<field id="custom_function" translate="label" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="custom_function" translate="label" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom js function</label>
<comment><![CDATA[The valid js function starting with { and finishing with }]]></comment>
<depends>
<field id="custom_function_active">1</field>
</depends>
</field>
<field id="image_quality" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="image_quality" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Image Quality</label>
<source_model>Scaleflex\Cloudimage\Model\Config\Source\ImageQuality</source_model>
<comment><![CDATA[The smaller the value, the more your image will be compressed. Careful — the quality of the image will decrease as well. By default, 90.]]></comment>
</field>
<field id="ignore_svg" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="ignore_svg" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Ignore SVG images</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[By default, yes.]]></comment>
</field>
<field id="fortorama_compatibility" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="fortorama_compatibility" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Fotorama Compatibility Mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Fotorama compatibility mode, default no]]></comment>
Expand All @@ -90,11 +90,16 @@
<source_model>Scaleflex\Cloudimage\Model\Config\Source\PixelRatio</source_model>
<comment><![CDATA[List of supported device pixel ratios, eg: 2 for Retina devices]]></comment>
</field>
<field id="library_options" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="orgifsml" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Prevent Image Resize</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[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. By default, yes.]]></comment>
</field>
<field id="library_options" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Library Options</label>
<comment><![CDATA[For advanced users only! This will modify the library URL. Must begin with the symbol &. By default, leave empty.]]></comment>
</field>
<field id="remove_v7" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="remove_v7" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Remove v7</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Removes the "/v7" part in URL format. Activate for token created after October 20th 2021.]]></comment>
Expand Down
6 changes: 4 additions & 2 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
</options>
<advanced>
<image_quality>90</image_quality>
<ignore_svg>1</ignore_svg>
<fortorama_compatibility>0</fortorama_compatibility>
<ignore_svg>0</ignore_svg>
<fortorama_compatibility>1</fortorama_compatibility>
<devicepixelratio>2</devicepixelratio>
<orgifsml>1</orgifsml>
<remove_v7>1</remove_v7>
</advanced>
</scaleflex_cloudimage>
</default>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Scaleflex_Cloudimage" setup_version="2.0.2">
<module name="Scaleflex_Cloudimage" setup_version="2.0.3">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down