Files
lucent-laravel/front/js/svelte/files/imageserver.js
T

33 lines
957 B
JavaScript
Raw Normal View History

2023-10-02 23:10:49 +03:00
2024-08-18 17:23:18 +03:00
export function imgurl(channel,record) {
if (record._file.mime === "image/svg+xml") {
return fileurl(channel, record);
2023-10-20 21:17:43 +03:00
}
2024-09-20 13:39:45 +03:00
return channel.filesUrl + `/thumbs/${record._file.disk}/${record._file.path}`;
2023-10-02 23:10:49 +03:00
}
2024-08-18 17:23:18 +03:00
export function fileurl(channel, record) {
2024-09-20 13:39:45 +03:00
return channel.filesUrl + `/${record._file.disk}/${record._file.path}`;
2023-10-02 23:10:49 +03:00
}
2024-08-18 17:23:18 +03:00
export function htmlurl(channel,record, preset) {
let html = "";
let url = fileurl(channel,record)
if (record._file.width > 0) {
let presetUrl = url;
if (preset) {
2024-09-20 13:39:45 +03:00
presetUrl = channel.filesUrl + `/templates/${preset}/${record._file.disk}/${record._file.path}`;
2024-08-18 17:23:18 +03:00
}
html = `<img src="${presetUrl}" alt="${record._file.path}" />`
} else if (record._file.mime === "image/svg+xml") {
html = `<img src="${url}" alt="${record._file.path}"/>`
} else {
html = `<a href="${url}">${record._file.originalName}</a>`
}
return html;
}