14 lines
528 B
TypeScript
14 lines
528 B
TypeScript
export function assetPreviewUrl(asset: { id: string }) {
|
|
return `/api/assets/${encodeURIComponent(asset.id)}/download?inline=1`;
|
|
}
|
|
|
|
export function materialPreviewUrl(material: { id?: string; url: string }) {
|
|
return material.id ? assetPreviewUrl({ id: material.id }) : material.url;
|
|
}
|
|
|
|
export function storedAssetPreviewUrl(url: string | undefined, assets: Array<{ id: string; url: string }>) {
|
|
if (!url) return "";
|
|
const asset = assets.find((item) => item.url === url);
|
|
return asset ? assetPreviewUrl(asset) : url;
|
|
}
|