diff --git a/class2.php b/class2.php
index 1b894881d..60f40f1ee 100755
--- a/class2.php
+++ b/class2.php
@@ -418,11 +418,6 @@ $pref = e107::getPref(); // include pref class.
$sysprefs = new prefs;
//DEPRECATED, BC, call e107::getPref/findPref() instead
-
-if(e_ADMIN_AREA !== true && !isset($_E107['no_parser']) && !empty($pref['thumb_to_webp']) && (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false))
-{
- $tp->setConvertToWebP(true);
-}
//this could be part of e107->init() method now, prefs will be auto-initialized
//when proper called (e107::getPref())
// $e107->set_base_path(); moved to init().
diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index bc930e8b1..7f67c4651 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -250,7 +250,6 @@ class e_parse
private $bootstrap;
private $fontawesome;
- private $convertToWebP = false;
private $removedList = array();
private $nodesToDelete = array();
@@ -2361,11 +2360,6 @@ 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';
@@ -2442,9 +2436,9 @@ class e_parse
}
- if(!empty($options['type']) && ($options['type'] === 'webp'))
+ if(!empty($options['type']))
{
- $thurl .= '&type=webp';
+ $thurl .= '&type='.$options['type'];
}
@@ -3592,15 +3586,6 @@ class e_parse
$this->bootstrap = (int) $version;
}
- /**
- * @param bool $bool
- */
- public function setConvertToWebP($bool)
- {
-
- $this->convertToWebP = (bool) $bool;
- }
-
/**
* Add leading zeros to a number. eg. 3 might become 000003
diff --git a/e107_handlers/e_thumbnail_class.php b/e107_handlers/e_thumbnail_class.php
index 6391464fc..8b1c9d133 100644
--- a/e107_handlers/e_thumbnail_class.php
+++ b/e107_handlers/e_thumbnail_class.php
@@ -45,6 +45,8 @@ class e_thumbnail
protected $_upsize = true;
+ protected $_forceWebP = false;
+
/**
* Constructor - init paths
*
@@ -86,6 +88,7 @@ class e_thumbnail
$this->_upsize = ((isset($this->_request['w']) && $this->_request['w'] > 110) || (isset($this->_request['aw']) && ($this->_request['aw'] > 110))); // don't resizeUp the icon images.
+ $this->_forceWebP = empty($this->_request['type']) && !empty($pref['thumb_to_webp']) && (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false) ? true : false;
// var_dump($this);
// exit;
return null;
@@ -156,7 +159,7 @@ class e_thumbnail
{
$thumbnfo = pathinfo($this->_src_path);
- if(!empty($this->_request['type']) && $this->_request['type'] == 'webp')
+ if($this->_forceWebP === true || (!empty($this->_request['type']) && $this->_request['type'] == 'webp'))
{
$thumbnfo['extension'] = 'webp';
}
diff --git a/e107_tests/tests/unit/e_parseTest.php b/e107_tests/tests/unit/e_parseTest.php
index 101929133..18aedb6ec 100644
--- a/e107_tests/tests/unit/e_parseTest.php
+++ b/e107_tests/tests/unit/e_parseTest.php
@@ -2301,25 +2301,7 @@ while($row = $sql->fetch())
$result5 = $this->tp->toImage($src, ['type'=>'webp']);
$this->assertStringContainsString('&type=webp', $result5); // src
- $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);
-
- // $result6 = str_replace($tempDir, '', $result6);
- $expected = str_replace("\r", '', $expected);
- $this->assertSame($expected,$result6);
- $this->tp->setConvertToWebP(false);
$tests = array(