. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Factory; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; /** * Create a thumbnail of a file, for use on the admin page. */ class AdminMediaFileThumbnail implements RequestHandlerInterface { /** * Show an image/thumbnail, with/without a watermark. * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $filesystem = Factory::filesystem()->data(); $params = (array) $request->getQueryParams(); $path = $params['path'] ?? ''; return Factory::image()->thumbnailResponse($filesystem, $path, 120, 120, 'contain'); } }