2026-05-05 19:21:59 +03:00
|
|
|
export function imgurl(channel, file) {
|
|
|
|
|
if (file.mime === "image/svg+xml") {
|
|
|
|
|
return fileurl(channel, file);
|
|
|
|
|
}
|
2026-05-14 21:15:33 +03:00
|
|
|
const webpPath = file.path.slice(0, file.path.lastIndexOf(".")) + ".webp";
|
|
|
|
|
return channel.filesUrl + `/thumbs/${webpPath}`;
|
2023-10-02 23:10:49 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-14 22:49:47 +03:00
|
|
|
export function presetUrl(channel, file, preset) {
|
|
|
|
|
if (file.mime === "image/svg+xml") {
|
|
|
|
|
return fileurl(channel, file);
|
|
|
|
|
}
|
|
|
|
|
const webpPath = file.path.slice(0, file.path.lastIndexOf(".")) + ".webp";
|
|
|
|
|
return channel.filesUrl + `/templates/${preset}/${webpPath}`;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-05 19:21:59 +03:00
|
|
|
export function fileurl(channel, file) {
|
|
|
|
|
return channel.filesUrl + `/${file.path}`;
|
2023-10-02 23:10:49 +03:00
|
|
|
}
|
2024-08-18 17:23:18 +03:00
|
|
|
|
2026-05-05 19:21:59 +03:00
|
|
|
export function htmlurl(channel, file, preset) {
|
|
|
|
|
let html = "";
|
|
|
|
|
let url = fileurl(channel, file);
|
2024-08-18 17:23:18 +03:00
|
|
|
|
2026-05-05 19:21:59 +03:00
|
|
|
if (file.width > 0) {
|
|
|
|
|
let presetUrl = url;
|
|
|
|
|
if (preset) {
|
2026-05-14 21:15:33 +03:00
|
|
|
const webpPath = file.path.slice(0, file.path.lastIndexOf(".")) + ".webp";
|
|
|
|
|
presetUrl = channel.filesUrl + `/templates/${preset}/${webpPath}`;
|
2024-08-18 17:23:18 +03:00
|
|
|
}
|
2026-05-05 19:21:59 +03:00
|
|
|
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>`;
|
|
|
|
|
}
|
2024-08-18 17:23:18 +03:00
|
|
|
|
2026-05-05 19:21:59 +03:00
|
|
|
return html;
|
2024-08-18 17:23:18 +03:00
|
|
|
}
|