mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 02:40:08 +00:00
feat(utils): support animated webps in formatImageUrl() (#4725)
This commit is contained in:
@@ -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' : ''}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user