feat(cms-images): forward dpr + format=auto to RustyCMS
- 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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user