diff --git a/modules/Cockpit/Controller/RestApi.php b/modules/Cockpit/Controller/RestApi.php index 988de91a1..eab5bb07c 100644 --- a/modules/Cockpit/Controller/RestApi.php +++ b/modules/Cockpit/Controller/RestApi.php @@ -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 = [ diff --git a/modules/Cockpit/Controller/Utils.php b/modules/Cockpit/Controller/Utils.php index 85cee6d92..9d6131c79 100644 --- a/modules/Cockpit/Controller/Utils.php +++ b/modules/Cockpit/Controller/Utils.php @@ -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)),