diff --git a/src/Lib/SqliteImageDb.php b/src/Lib/SqliteImageDb.php index a79adb6..1e9cdc2 100644 --- a/src/Lib/SqliteImageDb.php +++ b/src/Lib/SqliteImageDb.php @@ -27,7 +27,12 @@ class SqliteImageDb implements ImageDb { } public function findImage(string $path, ResizeParams $params): Image | null { - $stmt = $this->db->prepare('SELECT * FROM images WHERE path = :path AND width = :width AND height = :height AND quality = :quality'); + $query = "SELECT * FROM images WHERE path = :path"; + $query .= $params->width ? " AND width = :width" : " AND width IS NULL"; + $query .= $params->height ? " AND height = :height" : " AND height IS NULL"; + $query .= $params->quality ? " AND quality = :quality" : " AND quality IS NULL"; + + $stmt = $this->db->prepare($query); $stmt->execute([ ':path' => $path, ':width' => $params->width,