/** * Avatar imager helpers. * * Browser and server markup use the same runtime-configured avatar proxy. */ export type { AvatarOptions } from "@/types/admin"; import type { AvatarOptions } from "@/types/admin"; /** * Build an avatar image URL using the configured imager. * Uses effect=14 and img_format=apng by default for epicnabbo.nl compatibility. * Preserves the user's stored figure so the rendered avatar matches the account. * Omits default parameters (direction=2, head_direction=3, size=m) for cleaner URLs. */ export function getAvatarUrl( figure: string, options: AvatarOptions = {}, ): string { const { size = "m", direction = 2, headDirection = 3, headOnly = false, gesture, action, effect = 14, img_format = "apng", } = options; const params = new URLSearchParams({ figure, img_format, effect: String(effect), }); // Only add non-default params if (direction !== 2) params.set("direction", String(direction)); if (headDirection !== 3) params.set("head_direction", String(headDirection)); if (size !== "m") params.set("size", size); if (headOnly) params.set("headonly", "1"); if (gesture) params.set("gesture", gesture); if (action) params.set("action", action); const base = "/api/imaging/avatar"; return `${base}?${params.toString()}`; }