Closed yjmtmtk closed 1 year ago
This would work.
public function thumbnail($id = null) { $this->helper('session')->close(); $mime = $this->param('mime', 'auto'); if ($mime == 'auto') { $mime = null; //if (strpos($this->app->request->headers['Accept'] ?? '', 'image/webp') !== false) { if (strpos($_SERVER['HTTP_ACCEPT'] ?? '', 'image/webp') !== false) { $gdinfo = \gd_info(); $mime = isset($gdinfo['WebP Support']) && $gdinfo['WebP Support'] ? 'webp' : null; } } $src = $this->param('src', $id); $options = [ 'src' => $src, 'fp' => $this->param('fp', null), 'mode' => $this->param('m', 'thumbnail'), 'mime' => $mime, 'filters' => (array) $this->param('f', []), 'width' => intval($this->param('w', null)), 'height' => intval($this->param('h', null)), 'quality' => intval($this->param('q', 30)), 'rebuild' => intval($this->param('r', false)), 'timestamp' => $this->param('t', null), ]; $thumbUrl = $this->helper('asset')->image($options); if (!$thumbUrl || isset($thumbUrl['error'])) { return false; } if($this->param('re:int', 1)) { $this->app->reroute($thumbUrl); } return ['url' => $thumbUrl]; }
This would work.