2023-02-02 04:55:45 +09:00
|
|
|
import { query } from "@/scripts/url";
|
|
|
|
import { url } from "@/config";
|
2023-01-25 08:51:34 +09:00
|
|
|
|
2023-02-02 04:55:45 +09:00
|
|
|
export function getProxiedImageUrl(imageUrl: string, type?: "preview"): string {
|
2023-01-25 08:51:34 +09:00
|
|
|
return `${url}/proxy/image.webp?${query({
|
|
|
|
url: imageUrl,
|
2023-02-02 04:55:45 +09:00
|
|
|
fallback: "1",
|
|
|
|
...(type ? { [type]: "1" } : {}),
|
2023-01-25 08:51:34 +09:00
|
|
|
})}`;
|
|
|
|
}
|
|
|
|
|
2023-02-02 04:55:45 +09:00
|
|
|
export function getProxiedImageUrlNullable(
|
|
|
|
imageUrl: string | null | undefined,
|
|
|
|
type?: "preview",
|
|
|
|
): string | null {
|
2023-01-25 08:51:34 +09:00
|
|
|
if (imageUrl == null) return null;
|
|
|
|
return getProxiedImageUrl(imageUrl, type);
|
|
|
|
}
|