fix: make getAvatarUrl auto-convert figure strings
- Update getAvatarUrl in imager.ts to use getNewFormatFigure for automatic conversion - Update me/page.tsx to use avatarImageUrl (which also converts) - This ensures all avatar URLs use the short epicnabbo.nl format
This commit is contained in:
1 parent
2f708bcf11
commit
3213126a12
2 files changed
+7
-4
No files matched your search
@@ -19,8 +19,8 @@ import {
|
|||||||
WebsiteLoginLogs,
|
WebsiteLoginLogs,
|
||||||
WebsiteSetting,
|
WebsiteSetting,
|
||||||
} from "@/lib/db";
|
} from "@/lib/db";
|
||||||
|
import { avatarImageUrl } from "@/lib/format";
|
||||||
import { resolveHotelName } from "@/lib/hotel-name";
|
import { resolveHotelName } from "@/lib/hotel-name";
|
||||||
import { getAvatarUrl } from "@/lib/imager";
|
|
||||||
import { siteSettings } from "@/lib/services/site-settings";
|
import { siteSettings } from "@/lib/services/site-settings";
|
||||||
import CopyReferralButton from "./CopyReferralButton";
|
import CopyReferralButton from "./CopyReferralButton";
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ export default async function MePage({
|
|||||||
: "Never";
|
: "Never";
|
||||||
const referralLink = `/register?ref=${encodeURIComponent(user.username)}`;
|
const referralLink = `/register?ref=${encodeURIComponent(user.username)}`;
|
||||||
|
|
||||||
const avatarFull = getAvatarUrl(user.look, {
|
const avatarFull = avatarImageUrl(user.look, {
|
||||||
size: "l",
|
size: "l",
|
||||||
direction: 2,
|
direction: 2,
|
||||||
});
|
});
|
||||||
@@ -498,7 +498,7 @@ export default async function MePage({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={getAvatarUrl(friend.look, {
|
src={avatarImageUrl(friend.look, {
|
||||||
size: "s",
|
size: "s",
|
||||||
headOnly: true,
|
headOnly: true,
|
||||||
})}
|
})}
|
||||||
|
|||||||
+4
-1
@@ -8,6 +8,7 @@
|
|||||||
export type { AvatarOptions } from "@/types/admin";
|
export type { AvatarOptions } from "@/types/admin";
|
||||||
|
|
||||||
import { env } from "@/env";
|
import { env } from "@/env";
|
||||||
|
import { getNewFormatFigure } from "@/lib/figure-convert";
|
||||||
import type { AvatarOptions } from "@/types/admin";
|
import type { AvatarOptions } from "@/types/admin";
|
||||||
|
|
||||||
const DEFAULT_IMAGER_URL = "https://epicnabbo.nl/imaging/avatarimage";
|
const DEFAULT_IMAGER_URL = "https://epicnabbo.nl/imaging/avatarimage";
|
||||||
@@ -27,11 +28,13 @@ export function resolveImagerBase(): string {
|
|||||||
/**
|
/**
|
||||||
* Build an avatar image URL using the configured imager.
|
* Build an avatar image URL using the configured imager.
|
||||||
* Uses effect=14 and img_format=apng by default for epicnabbo.nl compatibility.
|
* Uses effect=14 and img_format=apng by default for epicnabbo.nl compatibility.
|
||||||
|
* Automatically converts old Habbo figure format to new epicnabbo.nl format.
|
||||||
*/
|
*/
|
||||||
export function getAvatarUrl(
|
export function getAvatarUrl(
|
||||||
figure: string,
|
figure: string,
|
||||||
options: AvatarOptions = {},
|
options: AvatarOptions = {},
|
||||||
): string {
|
): string {
|
||||||
|
const convertedFigure = getNewFormatFigure(figure);
|
||||||
const {
|
const {
|
||||||
size = "m",
|
size = "m",
|
||||||
direction = 2,
|
direction = 2,
|
||||||
@@ -44,7 +47,7 @@ export function getAvatarUrl(
|
|||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
figure,
|
figure: convertedFigure,
|
||||||
direction: String(direction),
|
direction: String(direction),
|
||||||
head_direction: String(headDirection),
|
head_direction: String(headDirection),
|
||||||
size,
|
size,
|
||||||
|
|||||||
Reference in new issue
Block a user