Skip to content

Commit 4d437b6

Browse files
authored
Merge pull request #11 from scaleflex/develop
update v 2.0.3
2 parents b7afc7f + c71ff74 commit 4d437b6

File tree

10 files changed

+68
-36
lines changed

10 files changed

+68
-36
lines changed

Block/Tag.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function getConfigToString(): string
7171
$config .= 'processQueryString: function (props) ' . $this->config->getCustomFunction() . ', ';
7272
}
7373
$config .= 'devicePixelRatioList: ' . $this->formatRatioList($this->config->getDevicePixelRatio()) . ', ';
74+
if ($this->config->isOrgIfSml()) {
75+
$config .= 'params: {org_if_sml: 1}, ';
76+
}
7477
$config .= 'token:\'' . $this->config->getToken() . '\' ';
7578
return $config;
7679
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.0.3] - 2022-04-27
6+
7+
* Support Multiple store views(websites)
8+
* Add config to prevent image resize when set Device Pixel Max Ratio equal to 2
9+
510
## [2.0.2] - 2022-04-08
611

712
* Add Fotorama Compatibility Mode option

Helper/Config.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ class Config extends AbstractHelper
3636
const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7 = 'scaleflex_cloudimage/advanced/remove_v7';
3737
const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY = 'scaleflex_cloudimage/advanced/fortorama_compatibility';
3838
const XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO = 'scaleflex_cloudimage/advanced/devicepixelratio';
39+
const XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_ORG_IF_SML = 'scaleflex_cloudimage/advanced/orgifsml';
3940

4041
/**
4142
* @return bool
4243
*/
4344
public function getApiUrl()
4445
{
45-
return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_CDN_API_URL);
46+
return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_CDN_API_URL, ScopeInterface::SCOPE_STORE);
4647
}
4748

4849
/**
@@ -54,7 +55,7 @@ public function getToken()
5455
{
5556
return $this->scopeConfig->getValue(
5657
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_GENERAL_TOKEN,
57-
ScopeInterface::SCOPE_WEBSITE
58+
ScopeInterface::SCOPE_STORE
5859
);
5960
}
6061

@@ -103,7 +104,8 @@ public function getCustomFunction()
103104
public function getImageQuality()
104105
{
105106
$imageQuality = (int)$this->scopeConfig->getValue(
106-
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_IMAGE_QUALITY
107+
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_IMAGE_QUALITY,
108+
ScopeInterface::SCOPE_STORE
107109
);
108110
if ($imageQuality > 0 && $imageQuality <= 100) {
109111
return $imageQuality;
@@ -118,7 +120,7 @@ public function getImageQuality()
118120
*/
119121
public function getLibraryOptions()
120122
{
121-
$options = $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_LIBRARY_OPTIONS);
123+
$options = $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_LIBRARY_OPTIONS, ScopeInterface::SCOPE_STORE);
122124
if (is_string($options) && strlen(trim($options)) > 0) {
123125
return trim($options);
124126
}
@@ -166,7 +168,7 @@ public function isDoNotReplaceUrl()
166168
{
167169
return (bool)$this->scopeConfig->getValue(
168170
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_DO_NOT_REPLACE_URL,
169-
ScopeInterface::SCOPE_WEBSITE
171+
ScopeInterface::SCOPE_STORE
170172
);
171173
}
172174

@@ -177,7 +179,7 @@ public function isIgnoreNodeImgSize()
177179
{
178180
return (bool)$this->scopeConfig->getValue(
179181
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_IGNORE_NODE_IMG_SIZE,
180-
ScopeInterface::SCOPE_WEBSITE
182+
ScopeInterface::SCOPE_STORE
181183
);
182184
}
183185

@@ -188,7 +190,18 @@ public function isIgnoreStyleImgSize()
188190
{
189191
return (bool)$this->scopeConfig->getValue(
190192
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_IGNORE_STYLE_IMG_SIZE,
191-
ScopeInterface::SCOPE_WEBSITE
193+
ScopeInterface::SCOPE_STORE
194+
);
195+
}
196+
197+
/**
198+
* @return bool
199+
*/
200+
public function isOrgIfSml()
201+
{
202+
return (bool)$this->scopeConfig->getValue(
203+
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_ORG_IF_SML,
204+
ScopeInterface::SCOPE_STORE
192205
);
193206
}
194207

@@ -201,7 +214,7 @@ public function isLazyLoading()
201214
{
202215
return (bool)$this->scopeConfig->getValue(
203216
self::XML_PATH_SCALEFLEX_CLOUDIMAGE_OPTIONS_LAZY_LOADING,
204-
ScopeInterface::SCOPE_WEBSITE
217+
ScopeInterface::SCOPE_STORE
205218
);
206219
}
207220

@@ -212,7 +225,7 @@ public function isLazyLoading()
212225
*/
213226
public function isIgnoreSvg()
214227
{
215-
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_PROCESS_SVG);
228+
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_PROCESS_SVG, ScopeInterface::SCOPE_STORE);
216229
}
217230

218231

@@ -223,7 +236,7 @@ public function isIgnoreSvg()
223236
*/
224237
public function getDevicePixelRatio()
225238
{
226-
return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO);
239+
return $this->scopeConfig->getValue(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_DEVICEPIXELRATIO, ScopeInterface::SCOPE_STORE);
227240
}
228241

229242
/**
@@ -233,13 +246,13 @@ public function getDevicePixelRatio()
233246
*/
234247
public function isRemoveV7()
235248
{
236-
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7);
249+
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_REMOVE_V7, ScopeInterface::SCOPE_STORE);
237250
}
238251

239252
/**
240253
* @return bool
241254
*/
242255
public function isFotoramaCompatibility() {
243-
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY);
256+
return $this->scopeConfig->isSetFlag(self::XML_PATH_SCALEFLEX_CLOUDIMAGE_ADVANCED_FOTORAMA_COMPATIBILITY, ScopeInterface::SCOPE_STORE);
244257
}
245258
}

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ Once the steps listed above are completed enter your Cloudimage token into the S
6464
Stores > Configuration > Cloudimage By Scaleflex > Cloudimage
6565
```
6666

67-
![Scaleflex Cloudimage Plugin Configuration](doc/images/cloudimage_plugin_config.png "Scaleflex Cloudimage Configuration Page")
67+
![Scaleflex Cloudimage Plugin Configuration](doc/images/cloudimage_plugin_config_2.0.3.png "Scaleflex Cloudimage Configuration Page")
6868

6969
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.
7070

7171
After saving the configuration, you will be asked to flush your Magento cache.
7272

7373
## Options
7474

75+
**(New) Support multiple websites and store views, now you can have difference token for each website.**
76+
7577
Following options are available:
7678

7779
**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
9698

9799
**Ignore SVG images**: If enabled, all SVG images will be skipped from acceleration as anyway vector images will not be compressed.
98100

99-
**(new) Fotorama Compatibility Mode**: Fotorama compatibility mode, default no
101+
**Fotorama Compatibility Mode**: Fotorama compatibility mode, default no
102+
103+
**Maximum "Pixel ratio"**: List of supported device pixel ratios, default is 2, eg: 2 for Retina devices
100104

101-
**(new) Maximum "Pixel ratio"**: List of supported device pixel ratios, default is 2, eg: 2 for Retina devices
105+
**(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
102106

103107
**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)
104108

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"ext-libxml": "*"
88
},
99
"type": "magento2-module",
10-
"version": "2.0.2",
10+
"version": "2.0.3",
1111
"license": "BSD-3-Clause",
1212
"authors": [
1313
{
4.27 KB
Loading
749 KB
Loading

etc/adminhtml/system.xml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,72 +15,72 @@
1515
<tab id="cloudimage" translate="label" sortOrder="200">
1616
<label>Cloudimage by Scaleflex</label>
1717
</tab>
18-
<section id="scaleflex_cloudimage" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
18+
<section id="scaleflex_cloudimage" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
1919
<label>Cloudimage</label>
2020
<tab>cloudimage</tab>
2121
<resource>Scaleflex_Cloudimage::config</resource>
22-
<group id="general" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
22+
<group id="general" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2323
<label>General</label>
24-
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
24+
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2525
<label>Scaleflex Cloudimage Active</label>
2626
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2727
<comment><![CDATA[]]></comment>
2828
</field>
29-
<field id="token" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
29+
<field id="token" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
3030
<label>Token</label>
3131
<depends>
3232
<field id="active">1</field>
3333
</depends>
3434
</field>
3535
</group>
36-
<group id="options" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
36+
<group id="options" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
3737
<label>Options</label>
38-
<field id="do_not_replace_url" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
38+
<field id="do_not_replace_url" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
3939
<label>Use origin URL</label>
4040
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
4141
<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>
4242
</field>
43-
<field id="ignore_node_img_size" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
43+
<field id="ignore_node_img_size" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
4444
<label>Ignore Image Size Node</label>
4545
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
4646
<comment><![CDATA[Can be useful for improving compatibility with some themes.]]></comment>
4747
</field>
48-
<field id="ignore_style_img_size" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
48+
<field id="ignore_style_img_size" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
4949
<label>Ignore Image Size Style</label>
5050
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
5151
<comment><![CDATA[Can be useful for improving compatibility with some themes.]]></comment>
5252
</field>
53-
<field id="lazy_loading" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
53+
<field id="lazy_loading" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
5454
<label>Lazy Loading</label>
5555
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
5656
<comment><![CDATA[If enabled, only images close to the current viewpoint will be loaded.]]></comment>
5757
</field>
5858
</group>
59-
<group id="advanced" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
59+
<group id="advanced" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
6060
<label>Advanced Configuration</label>
61-
<field id="custom_function_active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
61+
<field id="custom_function_active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
6262
<label>Inject Custom js function</label>
6363
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6464
<comment><![CDATA[Can be used to inject special js function depending on your theme.]]></comment>
6565
</field>
66-
<field id="custom_function" translate="label" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
66+
<field id="custom_function" translate="label" type="textarea" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
6767
<label>Custom js function</label>
6868
<comment><![CDATA[The valid js function starting with { and finishing with }]]></comment>
6969
<depends>
7070
<field id="custom_function_active">1</field>
7171
</depends>
7272
</field>
73-
<field id="image_quality" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
73+
<field id="image_quality" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
7474
<label>Image Quality</label>
7575
<source_model>Scaleflex\Cloudimage\Model\Config\Source\ImageQuality</source_model>
7676
<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>
7777
</field>
78-
<field id="ignore_svg" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
78+
<field id="ignore_svg" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
7979
<label>Ignore SVG images</label>
8080
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
8181
<comment><![CDATA[By default, yes.]]></comment>
8282
</field>
83-
<field id="fortorama_compatibility" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
83+
<field id="fortorama_compatibility" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
8484
<label>Fotorama Compatibility Mode</label>
8585
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
8686
<comment><![CDATA[Fotorama compatibility mode, default no]]></comment>
@@ -90,11 +90,16 @@
9090
<source_model>Scaleflex\Cloudimage\Model\Config\Source\PixelRatio</source_model>
9191
<comment><![CDATA[List of supported device pixel ratios, eg: 2 for Retina devices]]></comment>
9292
</field>
93-
<field id="library_options" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
93+
<field id="orgifsml" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
94+
<label>Prevent Image Resize</label>
95+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
96+
<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>
97+
</field>
98+
<field id="library_options" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
9499
<label>Custom Library Options</label>
95100
<comment><![CDATA[For advanced users only! This will modify the library URL. Must begin with the symbol &. By default, leave empty.]]></comment>
96101
</field>
97-
<field id="remove_v7" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0">
102+
<field id="remove_v7" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
98103
<label>Remove v7</label>
99104
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
100105
<comment><![CDATA[Removes the "/v7" part in URL format. Activate for token created after October 20th 2021.]]></comment>

etc/config.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
</options>
1010
<advanced>
1111
<image_quality>90</image_quality>
12-
<ignore_svg>1</ignore_svg>
13-
<fortorama_compatibility>0</fortorama_compatibility>
12+
<ignore_svg>0</ignore_svg>
13+
<fortorama_compatibility>1</fortorama_compatibility>
1414
<devicepixelratio>2</devicepixelratio>
15+
<orgifsml>1</orgifsml>
16+
<remove_v7>1</remove_v7>
1517
</advanced>
1618
</scaleflex_cloudimage>
1719
</default>

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
4-
<module name="Scaleflex_Cloudimage" setup_version="2.0.2">
4+
<module name="Scaleflex_Cloudimage" setup_version="2.0.3">
55
<sequence>
66
<module name="Magento_Catalog"/>
77
</sequence>

0 commit comments

Comments
 (0)