Files
lucent-laravel/front/js/svelte/files/imageserver.js
T
2026-05-05 19:21:59 +03:00

30 lines
760 B
JavaScript

export function imgurl(channel, file) {
if (file.mime === "image/svg+xml") {
return fileurl(channel, file);
}
return channel.filesUrl + `/thumbs/${file.path}`;
}
export function fileurl(channel, file) {
return channel.filesUrl + `/${file.path}`;
}
export function htmlurl(channel, file, preset) {
let html = "";
let url = fileurl(channel, file);
if (file.width > 0) {
let presetUrl = url;
if (preset) {
presetUrl = channel.filesUrl + `/templates/${preset}/${file.path}`;
}
html = `<img src="${presetUrl}" alt="${file.path}" />`;
} else if (file.mime === "image/svg+xml") {
html = `<img src="${url}" alt="${file.path}"/>`;
} else {
html = `<a href="${url}">${file.originalName}</a>`;
}
return html;
}