mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 20:11:46 +02:00
added a webp support check for engines
see: https://processwire.com/talk/topic/14236-webp-support/page/3/?tab=comments#comment-185020
This commit is contained in:
@@ -57,6 +57,7 @@ class ImageSizerEngineGD extends ImageSizerEngine {
|
||||
// and if it passes the mandatory requirements, we check particularly aspects here
|
||||
|
||||
switch($action) {
|
||||
|
||||
case 'imageformat':
|
||||
// compare current imagefile infos fetched from ImageInspector
|
||||
$requested = $this->getImageInfo(false);
|
||||
@@ -69,7 +70,16 @@ class ImageSizerEngineGD extends ImageSizerEngine {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'webp':
|
||||
if(!isset($this->wire('config')->webpSupportGD)) {
|
||||
// only call it once
|
||||
$gd = gd_info();
|
||||
$this->wire('config')->webpSupportGD = isset($gd['WebP Support']) ? $gd['WebP Support'] : false;
|
||||
}
|
||||
return $this->wire('config')->webpSupportGD;
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
/*
|
||||
$gd = gd_info();
|
||||
@@ -77,6 +87,7 @@ class ImageSizerEngineGD extends ImageSizerEngine {
|
||||
$png = isset($gd['PNG Support']) ? $gd['PNG Support'] : false;
|
||||
$gif = isset($gd['GIF Read Support']) && isset($gd['GIF Create Support']) ? $gd['GIF Create Support'] : false;
|
||||
$freetype = isset($gd['FreeType Support']) ? $gd['FreeType Support'] : false;
|
||||
$webp = isset($gd['WebP Support']) ? $gd['WebP Support'] : false;
|
||||
$this->config->gdReady = true;
|
||||
*/
|
||||
return true;
|
||||
|
@@ -833,7 +833,13 @@ class Pageimage extends Pagefile {
|
||||
|
||||
/** @var ImageSizerEngine $engine */
|
||||
$engine = $sizer->getEngine();
|
||||
|
||||
|
||||
/* if the current engine installation does not support webp, modify the options param */
|
||||
if(isset($options['webpAdd']) && $options['webpAdd'] && !$engine->supported('webp')) {
|
||||
$options['webpAdd'] = false;
|
||||
$engine->setOptions($options);
|
||||
}
|
||||
|
||||
// allow for ImageSizerEngine module settings for quality and sharpening to override system defaults
|
||||
// when they are not specified as an option to this resize() method
|
||||
$engineConfigData = $engine->getConfigData();
|
||||
@@ -1929,7 +1935,7 @@ class Pageimage extends Pagefile {
|
||||
$original,
|
||||
parent::__debugInfo(),
|
||||
array(
|
||||
'suffix' => $finalOptions['suffix'],
|
||||
'suffix' => isset($finalOptions['suffix']) ? $finalOptions['suffix'] : '',
|
||||
'extension' => $osInfo['extension']
|
||||
)
|
||||
));
|
||||
@@ -1993,7 +1999,8 @@ class Pageimage extends Pagefile {
|
||||
$enginesArray = array(
|
||||
'neededEngineSupport' => strtoupper($oSizer->getImageInfo()),
|
||||
'installedEngines' => $a,
|
||||
'selectedEngine' => $oSizer->getEngine()->className
|
||||
'selectedEngine' => $oSizer->getEngine()->className,
|
||||
'engineWebpSupport' => $oSizer->getEngine()->supported('webp')
|
||||
);
|
||||
unset($a, $moduleName, $configData, $engines, $priority, $modules, $oSizer);
|
||||
|
||||
|
Reference in New Issue
Block a user