2022-11-12 09:39:11 +09:00
|
|
|
import { query } from '@/scripts/url';
|
|
|
|
import { url } from '@/config';
|
|
|
|
|
2022-11-27 08:57:11 +09:00
|
|
|
export function getProxiedImageUrl(imageUrl: string, type?: 'preview'): string {
|
2022-11-12 09:39:11 +09:00
|
|
|
return `${url}/proxy/image.webp?${query({
|
|
|
|
url: imageUrl,
|
2022-11-27 08:57:11 +09:00
|
|
|
...(type ? { [type]: "1" } : {}),
|
2022-11-12 09:39:11 +09:00
|
|
|
})}`;
|
|
|
|
}
|
|
|
|
|
2022-11-27 08:57:11 +09:00
|
|
|
export function getProxiedImageUrlNullable(imageUrl: string | null | undefined, type?: 'preview'): string | null {
|
2022-11-12 09:39:11 +09:00
|
|
|
if (imageUrl == null) return null;
|
2022-11-27 08:57:11 +09:00
|
|
|
return getProxiedImageUrl(imageUrl, type);
|
2022-11-12 09:39:11 +09:00
|
|
|
}
|