feat(gifs): serve every medium, tiny and nano variant klipy offers (#1829)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-24 12:26:44 +02:00
1 parent d339b82f8e
commit 56f6009390
6 files changed
+440 -130

No files matched your search

@@ -0,0 +1,45 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
export const FORMAT_CONTENT_TYPES: Record<string, string> = {
gif: 'image/gif',
loopedmp4: 'video/mp4',
mediumgif: 'image/gif',
mediummp4: 'video/mp4',
mediumwebm: 'video/webm',
mediumwebp: 'image/webp',
mp4: 'video/mp4',
nanogif: 'image/gif',
nanomp4: 'video/mp4',
nanowebm: 'video/webm',
nanowebp: 'image/webp',
tinygif: 'image/gif',
tinymp4: 'video/mp4',
tinywebm: 'video/webm',
tinywebp: 'image/webp',
webm: 'video/webm',
webp: 'image/webp',
};
export const PREVIEW_FORMAT_PRIORITY = [
'tinywebm',
'tinymp4',
'mediumwebm',
'mediummp4',
'webm',
'mp4',
'loopedmp4',
'nanowebm',
'nanomp4',
'tinywebp',
'tinygif',
'mediumwebp',
'webp',
'mediumgif',
'gif',
'nanowebp',
'nanogif',
] as const;
export function inferFormatContentType(formatKey: string): string {
return FORMAT_CONTENT_TYPES[formatKey] ?? '';
}
@@ -55,7 +55,7 @@ export const GifResponse = z.object({
media: z
.record(z.string(), GifMediaFormat)
.describe(
'Map of format-name → media descriptor. Keys are provider-issued format names (e.g. "webm", "mp4", "webp", "gif", "tinygif", "nanogif"). Clients without webm support should pick "webp" / "gif" / "tinygif" / "nanogif" in that order.',
'Map of format-name → media descriptor. Keys are a size prefix (none for full size, "medium", "tiny", "nano") joined to a codec name ("webm", "mp4", "webp", "gif"), plus "loopedmp4". Video keys are "webm" / "mp4" / "loopedmp4" / "mediumwebm" / "mediummp4" / "tinywebm" / "tinymp4" / "nanowebm" / "nanomp4"; image keys are "webp" / "gif" / "mediumwebp" / "mediumgif" / "tinywebp" / "tinygif" / "nanowebp" / "nanogif". Every key is optional, so clients must walk a priority list rather than index a single key. Clients that cannot decode the video keys should prefer "tinywebp" / "tinygif" / "mediumwebp" / "mediumgif" / "webp" / "gif" / "nanowebp" / "nanogif" in that order.',
),
placeholder: z
.string()