feat(cms-images): forward dpr + format=auto to RustyCMS
Deploy / verify (push) Successful in 40s
Deploy / deploy (push) Successful in 1m2s

- Accept dpr query param (clamped 1..4) and include it in cache key so
  each density gets its own cached file.
- Accept format=auto and negotiate locally from the client's Accept
  header (avif > webp > jpeg) before building the cache key — concrete
  formats in the cache avoid cross-client leaks.
This commit is contained in:
Peter Meier
2026-04-23 13:36:38 +02:00
parent 50bb0ef398
commit 724b75b6bf
2 changed files with 27 additions and 2 deletions
+2
View File
@@ -29,6 +29,7 @@ export interface ImageTransformParams {
ar?: string;
fx?: number;
fy?: number;
dpr?: number;
}
const memoryCache = new Map<string, CachedImage>();
@@ -60,6 +61,7 @@ export function buildCacheKey(src: string, params: ImageTransformParams): string
if (params.ar) parts.push(`ar=${params.ar}`);
if (params.fx != null) parts.push(`fx=${roundFocal(params.fx)}`);
if (params.fy != null) parts.push(`fy=${roundFocal(params.fy)}`);
if (params.dpr != null) parts.push(`dpr=${roundFocal(params.dpr)}`);
return createHash('sha256').update(parts.join('|')).digest('hex').slice(0, 16);
}