dynamic images of products

This commit is contained in:
2026-05-18 10:13:50 +03:30
parent d52efb36e6
commit d6ebe782f3
4 changed files with 37 additions and 9 deletions
+17
View File
@@ -0,0 +1,17 @@
import { baseURL } from '@/themeConfig'
export interface ProductFile {
id?: number
url?: string | null
src?: string
}
export function getFileUrl(file?: ProductFile | null): string | null {
if (!file) return null
if (file.url) return file.url
if (!file.src) return null
if (/^https?:\/\//i.test(file.src)) return file.src
const base = baseURL.replace(/\/$/, '')
const path = file.src.replace(/^\//, '')
return `${base}/${path}`
}