1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-16 11:36:08 +02:00

Thumbnailer: Added option for on-the-fly conversion to WebP format. Example: toImage($src, ['w'=>'type'=>'webp']);

This commit is contained in:
Cameron
2020-12-08 09:10:26 -08:00
parent 005bff7e59
commit a094a8fb73
6 changed files with 110 additions and 28 deletions

View File

@@ -154,6 +154,18 @@ class e_thumbnail
$this->_request = (array) $array;
}
private function getImageInfo()
{
$thumbnfo = pathinfo($this->_src_path);
if(!empty($this->_request['type']) && $this->_request['type'] == 'webp')
{
$thumbnfo['extension'] = 'webp';
}
return $thumbnfo;
}
/**
* Validate and Sanitize the Request.
* @return bool true when request is okay.
@@ -223,7 +235,7 @@ class e_thumbnail
return $this;
}
$thumbnfo = pathinfo($this->_src_path);
$thumbnfo = $this->getImageInfo();
$options = $this->getRequestOptions();
$fname = e107::getParser()->thumbCacheFile($this->_src_path, $options);
$cache_filename = e_CACHE_IMAGE . $fname;
@@ -479,6 +491,11 @@ class e_thumbnail
$ret['c'] = 'T'; // default is 'Top';
}
if(!empty($this->_request['type']))
{
$ret['type'] = $this->_request['type'];
}
return $ret;
}