Files

33 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2024-09-27 16:27:37 +03:00
export function imgurl(channel, record) {
2024-08-18 17:23:18 +03:00
if (record._file.mime === "image/svg+xml") {
return fileurl(channel, record);
2023-10-20 21:17:43 +03:00
}
2024-10-09 23:36:24 +03:00
const pathAr = record._file.path.split("/");
return channel.disks[record._file.disk] + `/${pathAr[0]}/thumbs/${pathAr[1]}`;
2023-10-02 23:10:49 +03:00
}
2024-08-18 17:23:18 +03:00
export function fileurl(channel, record) {
2024-09-27 14:28:20 +03:00
return channel.disks[record._file.disk] + `/${record._file.path}`;
2023-10-02 23:10:49 +03:00
}
2024-08-18 17:23:18 +03:00
2024-09-27 16:27:37 +03:00
export function htmlurl(channel, record, preset) {
2024-08-18 17:23:18 +03:00
let html = "";
2024-09-27 16:27:37 +03:00
let url = fileurl(channel, record)
2024-08-18 17:23:18 +03:00
if (record._file.width > 0) {
let presetUrl = url;
if (preset) {
2024-10-09 23:36:24 +03:00
const pathAr = record._file.path.split("/");
presetUrl = channel.disks[record._file.disk] + `/${pathAr[0]}/templates/${preset}/${pathAr[1]}`;
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;
}