Skip to content

Commit dfe700a

Browse files
authored
Add: 'html_compress_exclude_pattern' config var
1 parent 6326c3a commit dfe700a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ParamonovavSpressHtmlCompress.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class ParamonovavSpressHtmlCompress implements PluginInterface
1111
{
1212
private $io, $html_compress_exclude = ['.htaccess','robots.txt','crossdomain.xml', 'sitemap.xml', 'rss.xml'];
1313

14+
private $html_compress_exclude_pattern = '/(.*)?\.(jpe?g|png|gif|ico|svg|psd|tiff|webm|mov|avi|mkv|mp4)$/i';
15+
1416
public function initialize(EventSubscriber $subscriber)
1517
{
1618
$subscriber-> addEventListener('spress.start', 'onStart');
@@ -37,13 +39,19 @@ public function onStart(EnvironmentEvent $event)
3739
{
3840
$this->html_compress_exclude = $configValues['html_compress_exclude'];
3941
}
42+
43+
if(isset($configValues['html_compress_exclude_pattern']))
44+
{
45+
$this->html_compress_exclude_pattern = $configValues['html_compress_exclude_pattern'];
46+
}
47+
4048
}
4149

4250
public function onAfterRenderPage(RenderEvent $event)
4351
{
4452
$id = $event-> getId();
4553

46-
if (in_array($id, $this-> html_compress_exclude) || preg_match('/(.*)?\.(jpe?g|png|gif|ico|svg|psd|tiff|webm|mov|avi|mkv|mp4)$/i', $id))
54+
if (in_array($id, $this-> html_compress_exclude) || preg_match($this->html_compress_exclude_pattern, $id))
4755
{
4856
return;
4957
}

0 commit comments

Comments
 (0)