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

This commit is contained in:
Awesome Stickz
2026-02-01 14:17:40 +05:30
committed by GitHub
parent 4eba7d2d61
commit b93d1f9294

View File

@@ -8,7 +8,10 @@ export interface ImageOptions {
/** Help format an image url. */
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' : ''}`;
}
/**