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