Fix it again

This commit is contained in:
Lewis Dale 2023-08-27 22:12:28 +01:00
parent a0580ad085
commit 519611d06b
3 changed files with 11 additions and 5 deletions

View File

@ -48,6 +48,7 @@ class Resizer
private function createVariant(Image $original, ResizeParams $params): string
{
$quality = $params->quality ?: -1;
$this->logger->info("Resizing image", ['params'=>$params]);
$original->toWidth($params->width ?? intval($_ENV["DEFAULT_WIDTH"]));

View File

@ -36,10 +36,15 @@ class SqliteImageDb implements ImageDb {
$query .= $params->quality ? ' AND quality = :quality' : ' AND quality IS NULL';
$stmt = $this->db->prepare($query);
$stmt->bindParam(':path', $path);
if ($params->width !== null) $stmt->bindParam(':width', $params->width);
if ($params->height !== null) $stmt->bindParam(':height', $params->height);
if ($params->quality !== null) $stmt->bindParam(':quality', $params->quality);
$queryParams = [
':path' => $path,
];
if ($params->width !== null) $queryParams[':width'] = $params->width;
if ($params->height !== null) $queryParams[':height'] = $params->height;
if ($params->quality !== null) $queryParams[':quality'] = $params->quality;
$stmt->execute($queryParams);
$this->logger->info("Querying images", ['query' => $stmt->queryString]);

View File

@ -12,7 +12,7 @@ class ResizeParams
public function __construct(array $params)
{
$this->width = intval($params['width']) ?: intval($_ENV["DEFAULT_WIDTH"]);
$this->width = isset($params['width']) ? intval($params['width']) : intval($_ENV["DEFAULT_WIDTH"]);
$this->height = intval($params['height']) ?: null;
$this->quality = isset($params['quality']) ? intval($params['quality']) : null;
}