Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to force enable DIO regardless of the full page cache settings #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand Down
8 changes: 8 additions & 0 deletions Model/View/Asset/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand Down
8 changes: 8 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,14 @@
target="_blank">image optimization guide</a> for caveats and details.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<!-- ===============================================
Force Enable Deep Image Optimization select field
================================================ -->
<field id="image_optimizations_forced" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Force Enable Deep Image Optimization</label>
<comment><![CDATA[Use this to forcefully enable deep image optimisation on instances that are not connected to fastly, for use on test environments]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<!-- ====================================================
JPEG image quality input field
===================================================== -->
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</fastly_blocking>
<fastly_image_optimization_configuration>
<image_optimizations>0</image_optimizations>
<image_optimizations_forced>0</image_optimizations_forced>
<image_optimization_force_lossy>0</image_optimization_force_lossy>
<image_optimization_image_quality>80</image_optimization_image_quality>
<image_optimization_bg_color>1</image_optimization_bg_color>
Expand Down