mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server: Fix rendering of SVG attachments (closes #226)
This commit is contained in:
parent
66108c1067
commit
ea1da1e155
@ -41,22 +41,21 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderSvgAttachment(image: BNote | BRevision, res: Response, attachmentName: string) {
|
function renderSvgAttachment(image: BNote | BRevision, res: Response, attachmentName: string) {
|
||||||
let svgString = '<svg/>'
|
let svg: string | Buffer = '<svg/>'
|
||||||
const attachment = image.getAttachmentByTitle(attachmentName);
|
const attachment = image.getAttachmentByTitle(attachmentName);
|
||||||
|
|
||||||
const content = attachment.getContent();
|
const content = attachment.getContent();
|
||||||
if (attachment && typeof content === "string") {
|
if (attachment) {
|
||||||
svgString = content;
|
svg = content;
|
||||||
} else {
|
} else {
|
||||||
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
|
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
|
||||||
const contentSvg = image.getJsonContentSafely()?.svg;
|
const contentSvg = image.getJsonContentSafely()?.svg;
|
||||||
|
|
||||||
if (contentSvg) {
|
if (contentSvg) {
|
||||||
svgString = contentSvg;
|
svg = contentSvg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const svg = svgString
|
|
||||||
res.set('Content-Type', "image/svg+xml");
|
res.set('Content-Type', "image/svg+xml");
|
||||||
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
|
res.set("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
res.send(svg);
|
res.send(svg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user