summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/media-proxy.ts
blob: aaf7f9e610280a65676d2dfd264fd3ca02429074 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { query } from '@/scripts/url';
import { url } from '@/config';

export function getProxiedImageUrl(imageUrl: string, type?: 'preview'): string {
	return `${url}/proxy/image.webp?${query({
		url: imageUrl,
		fallback: '1',
		...(type ? { [type]: '1' } : {}),
	})}`;
}

export function getProxiedImageUrlNullable(imageUrl: string | null | undefined, type?: 'preview'): string | null {
	if (imageUrl == null) return null;
	return getProxiedImageUrl(imageUrl, type);
}