fix: fallback to legacy keys for variant lookup

This commit is contained in:
William Valentin
2026-02-01 12:13:39 -08:00
parent 26e2d74d2b
commit 517e21d0b7
3 changed files with 71 additions and 17 deletions

View File

@@ -7,3 +7,25 @@ export function pickVariantKey(
);
return v?.key ?? null;
}
export function pickLegacyKeyForRequest(
input: {
asset: {
thumb_small_key: string | null;
thumb_med_key: string | null;
poster_key: string | null;
};
},
req: { kind: string; size: number },
) {
if (req.kind === "thumb" && req.size === 256) {
return input.asset.thumb_small_key ?? null;
}
if (req.kind === "thumb" && req.size === 768) {
return input.asset.thumb_med_key ?? null;
}
if (req.kind === "poster" && req.size === 256) {
return input.asset.poster_key ?? null;
}
return null;
}