get-image-url-fixed

This commit is contained in:
Untone 2024-01-23 18:31:59 +03:00
parent 2db840bba5
commit 90e02675ba

View File

@ -15,14 +15,14 @@ export const getImageUrl = (
src: string,
options: { width?: number; height?: number; noSizeUrlPart?: boolean } = {},
) => {
console.debug(src)
const filename = src.split('/')[-1]
const isAudio = src.toLowerCase().split('.')[-1] in ['wav', 'mp3', 'ogg', 'aif', 'flac']
//console.debug(src)
const filename = src.split('/').pop()
const isAudio = src.toLowerCase().split('.').pop() in ['wav', 'mp3', 'ogg', 'aif', 'flac']
const base = isAudio ? cdnUrl : `${thumborUrl}/unsafe/`
const sizeUrlPart = isAudio ? '' : getSizeUrlPart(options)
const res = `${base}${sizeUrlPart}production/${isAudio ? 'audio' : 'image'}/${filename}`
console.debug(res)
//console.debug(res)
return res
}