Skip to content

Commit

Permalink
use webp based previews in the assetmanager if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
aheinze committed Apr 8, 2021
1 parent d09ffd9 commit 689ca6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion modules/Cockpit/Controller/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function image() {
$mime = $this->param('mime', null);

if ($mime == 'auto' && strpos($this->app->request->headers['Accept'] ?? '', 'image/webp') !== false) {
$mime = 'image/webp';
$gdinfo = \gd_info();
$mime = isset($gdinfo['WebP Support']) && $gdinfo['WebP Support'] ? 'image/webp' : 'auto';
}

$options = [
Expand Down
12 changes: 10 additions & 2 deletions modules/Cockpit/Controller/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ public function thumb_url() {

\session_write_close(); // improve concurrency loading

$mime = $this->param('mime', 'auto');

if ($mime == 'auto' && strpos($this->app->request->headers['Accept'] ?? '', 'image/webp') !== false) {
$gdinfo = \gd_info();
$mime = isset($gdinfo['WebP Support']) && $gdinfo['WebP Support'] ? 'image/webp' : 'auto';
}


$options = [
'src' => $this->param('src', false),
'fp' => $this->param('fp', null),
'mode' => $this->param('m', 'thumbnail'),
'mime' => $this->param('mime', null),
'mime' => $mime,
'filters' => (array) $this->param('f', []),
'width' => intval($this->param('w', null)),
'height' => intval($this->param('h', null)),
'quality' => intval($this->param('q', 85)),
'quality' => intval($this->param('q', 80)),
'rebuild' => intval($this->param('r', false)),
'base64' => intval($this->param('b64', false)),
'output' => intval($this->param('o', false)),
Expand Down

0 comments on commit 689ca6d

Please sign in to comment.