diff --git a/class2.php b/class2.php
index cfba4b392..1b894881d 100755
--- a/class2.php
+++ b/class2.php
@@ -419,7 +419,7 @@ $sysprefs = new prefs;
//DEPRECATED, BC, call e107::getPref/findPref() instead
-if(e_ADMIN_AREA !== true && !isset($_E107['no_parser']) && !empty($pref['thumb_to_webp']))
+if(e_ADMIN_AREA !== true && !isset($_E107['no_parser']) && !empty($pref['thumb_to_webp']) && (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false))
{
$tp->setConvertToWebP(true);
}
diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index 67e0d8cf6..bc930e8b1 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -2361,6 +2361,11 @@ class e_parse
parse_str($options, $options);
}
+ if($this->convertToWebP)
+ {
+ $options['type'] = 'webp';
+ }
+
if(!empty($options['scale'])) // eg. scale the width height 2x 3x 4x. etc.
{
$options['return'] = 'src';
@@ -2559,6 +2564,7 @@ class e_parse
}
+
// $encode = $this->thumbEncode();;
if($width == null || $width === 'all')
{
@@ -4345,17 +4351,16 @@ class e_parse
}
$html = '';
-
+/*
if($this->convertToWebP)
{
- $parm['type'] = 'webp';
$source = $tp->thumbUrl($file, $parm);
$html = "\n";
if(!empty($parm['srcset']))
{
list($webPSourceSet, $webPSize) = explode(' ', $parm['srcset']);
- $html .= '';
+ $html .= '';
$html .= "\n";
$html .= '';
$html .= "\n";
@@ -4364,7 +4369,7 @@ class e_parse
$html .= '';
$html .= "\n";
- }
+ }*/
if(empty($path))
{
@@ -4373,7 +4378,7 @@ class e_parse
$html .= "
';
- $html .= ($this->convertToWebP) ? "\n" : '';
+ // $html .= ($this->convertToWebP) ? "\n" : '';
return $html;
diff --git a/e107_tests/tests/unit/e_parseTest.php b/e107_tests/tests/unit/e_parseTest.php
index 88c802a82..101929133 100644
--- a/e107_tests/tests/unit/e_parseTest.php
+++ b/e107_tests/tests/unit/e_parseTest.php
@@ -1192,6 +1192,11 @@ while($row = $sql->fetch())
'options' => array('w'=>300, 'h'=>200, 'scale'=>'2x'),
'expected' =>'/thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&w=600&h=400'
),
+ 4 => array(
+ 'path' => '{e_PLUGIN}gallery/images/horse.jpg',
+ 'options' => array('w'=>300, 'h'=>200, 'scale'=>'2x', 'type'=>'webp'),
+ 'expected' =>'/thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fhorse.jpg&w=600&h=400&type=webp'
+ ),
);
@@ -2298,14 +2303,15 @@ while($row = $sql->fetch())
$this->tp->setConvertToWebP(true);
$result6 = $this->tp->toImage($src);
+ $expected = '
';
-
+/*
$expected = '
-';
+';*/
// $tempDir = str_replace(['C:','\\'],['','/'], sys_get_temp_dir()).'/'; // FIXME
$result6 = preg_replace('/"([^"]*)thumb.php/','"thumb.php', $result6);