diff --git a/Model/Config.php b/Model/Config.php index 595484ff..5aea6e17 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -331,6 +331,12 @@ class Config extends \Magento\PageCache\Model\Config const XML_FASTLY_IMAGE_OPTIMIZATIONS = 'system/full_page_cache/fastly/fastly_image_optimization_configuration/image_optimizations'; + /** + * XML path to image optimizations flag forced + */ + const XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED + = 'system/full_page_cache/fastly/fastly_image_optimization_configuration/image_optimizations_forced'; + /** * XML path to automatic compression flag */ @@ -828,6 +834,10 @@ public function getGeoIpRedirectMapping() */ public function isImageOptimizationEnabled() { + if ($this->_scopeConfig->isSetFlag(self::XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED)) { + return true; + } + if ($this->isFastlyEnabled() !== true) { return false; } diff --git a/Model/Product/Image.php b/Model/Product/Image.php index 1c54ba8d..0b8825cd 100755 --- a/Model/Product/Image.php +++ b/Model/Product/Image.php @@ -78,6 +78,10 @@ private function isFastlyImageOptimizationEnabled() $this->isFastlyEnabled = false; } + if ($this->_scopeConfig->isSetFlag(Config::XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED)) { + $this->isFastlyEnabled = true; + } + return $this->isFastlyEnabled; } @@ -100,6 +104,10 @@ public function isForceLossyEnabled() $this->isForceLossyEnabled = false; } + if ($this->_scopeConfig->isSetFlag(Config::XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED)) { + $this->isFastlyEnabled = true; + } + return $this->isForceLossyEnabled; } diff --git a/Model/View/Asset/Image.php b/Model/View/Asset/Image.php index 84788b5e..afc7391b 100644 --- a/Model/View/Asset/Image.php +++ b/Model/View/Asset/Image.php @@ -182,6 +182,10 @@ private function isFastlyImageOptimizationEnabled() $this->isFastlyEnabled = false; } + if ($this->scopeConfig->isSetFlag(Config::XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED)) { + $this->isFastlyEnabled = true; + } + return $this->isFastlyEnabled; } @@ -204,6 +208,10 @@ public function isForceLossyEnabled() $this->isForceLossyEnabled = false; } + if ($this->scopeConfig->isSetFlag(Config::XML_FASTLY_IMAGE_OPTIMIZATIONS_FORCED)) { + $this->isFastlyEnabled = true; + } + return $this->isForceLossyEnabled; } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 4cf09340..ee7afef8 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -496,6 +496,14 @@ target="_blank">image optimization guide for caveats and details.]]> Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + diff --git a/etc/config.xml b/etc/config.xml index 31de15bd..5a805af9 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -45,6 +45,7 @@ 0 + 0 0 80 1