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