Skip to content

Commit f1a66e3

Browse files
authored
Webp (#26)
1 parent f654545 commit f1a66e3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Dispatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Dispatch
6565
protected $_acceptableTypes;
6666
protected $_bits = 0;
6767

68-
private const BIT_WEBP = 0b1;
68+
public const BIT_WEBP = 0b1;
6969
/**
7070
* @var ResponseCacheConfig
7171
*/

src/ResourceManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Exception;
55
use Packaged\Dispatch\Component\DispatchableComponent;
66
use Packaged\Dispatch\Component\FixedClassComponent;
7+
use Packaged\Helpers\BitWise;
78
use Packaged\Helpers\Path;
89
use Packaged\Helpers\Strings;
910
use Packaged\Helpers\ValueAs;
@@ -322,7 +323,7 @@ protected function _optimisePath($path, $relativeFullPath)
322323
$this->_optimizeWebP = ValueAs::bool(Dispatch::instance()->config()->getItem('optimisation', 'webp', false));
323324
}
324325

325-
if($this->_optimizeWebP
326+
if($this->_optimizeWebP && BitWise::has(($this->_dispatch ?: Dispatch::instance())->getBits(), Dispatch::BIT_WEBP)
326327
&& in_array(substr($path, -4), ['.jpg', 'jpeg', '.png', '.gif', '.bmp', 'tiff', '.svg'])
327328
&& file_exists($path . '.webp'))
328329
{

0 commit comments

Comments
 (0)