feat(utils): support animated webps in formatImageUrl() (#4725)

This commit is contained in:
Awesome Stickz
2026-02-01 09:47:40 +01:00
committed by GitHub
parent 4eba7d2d61
commit b93d1f9294
+4 -1
View File
@@ -8,7 +8,10 @@ export interface ImageOptions {
/** Help format an image url. */ /** Help format an image url. */
export function formatImageUrl(url: string, size: ImageSize = 128, format?: ImageFormat): string { export function formatImageUrl(url: string, size: ImageSize = 128, format?: ImageFormat): string {
return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'webp')}?size=${size}`; const animated = url.includes('/a_');
format ??= animated ? 'gif' : 'webp';
return `${url}.${format}?size=${size}${animated && format === 'webp' ? '&animated=true' : ''}`;
} }
/** /**