Line data Source code
1 : import { getMediaTypeFromFilename } from '@/utils/formatUtil'
2 :
3 : import { isCloud } from './types'
4 :
5 : /**
6 : * Appends `res=512` to the given URLSearchParams when in cloud mode
7 : * and the file is an image (or filename is unknown).
8 : *
9 : * The cloud backend resizes images server-side to prevent
10 : * the frontend from loading very large originals for previews.
11 : */
12 11608 : export function appendCloudResParam(
13 : params: URLSearchParams,
14 : filename?: string
15 : ): void {
16 : if (!isCloud) return
17 : if (
18 : filename &&
19 : (getMediaTypeFromFilename(filename) !== 'image' ||
20 : filename.toLowerCase().endsWith('.svg'))
21 : )
22 : return
23 : params.set('res', '512')
24 : }
|