feat: relativize linked images
This commit is contained in:
parent
0f0afeae8d
commit
b170941535
1 changed files with 18 additions and 0 deletions
|
@ -242,6 +242,11 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Images
|
||||||
|
console.debug("[SVG] Processing images.");
|
||||||
|
const images = processImages(svg);
|
||||||
|
console.info(`[SVG] Found ${images.length} images.`);
|
||||||
|
|
||||||
// Audio areas
|
// Audio areas
|
||||||
console.debug("[SVG] Processing audio areas.");
|
console.debug("[SVG] Processing audio areas.");
|
||||||
audioAreas = processAudio(svg);
|
audioAreas = processAudio(svg);
|
||||||
|
@ -386,6 +391,19 @@
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processImages(document: SVGElement): SVGImageElement[] {
|
||||||
|
const result: SVGImageElement[] = [];
|
||||||
|
Array.from(document.getElementsByTagName("image")).forEach((image) => {
|
||||||
|
console.debug(`[SVG/IMAGES] Found image #${image.id}.`);
|
||||||
|
const origPath = image.getAttribute("xlink:href").split("/");
|
||||||
|
let newHref = `content/images/${origPath[origPath.length - 1]}`;
|
||||||
|
newHref = newHref.replace(/jpg$/, "webp");
|
||||||
|
image.setAttribute("xlink:href", newHref);
|
||||||
|
result.push(image);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async function processScrolls(
|
async function processScrolls(
|
||||||
svg: SVGElement,
|
svg: SVGElement,
|
||||||
images: SVGImageElement[]
|
images: SVGImageElement[]
|
||||||
|
|
Loading…
Reference in a new issue