diff --git a/src/components/SVGContent.svelte b/src/components/SVGContent.svelte index 44c8c67..cbf98bb 100644 --- a/src/components/SVGContent.svelte +++ b/src/components/SVGContent.svelte @@ -242,6 +242,11 @@ }); }); + // Images + console.debug("[SVG] Processing images."); + const images = processImages(svg); + console.info(`[SVG] Found ${images.length} images.`); + // Audio areas console.debug("[SVG] Processing audio areas."); audioAreas = processAudio(svg); @@ -386,6 +391,19 @@ 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( svg: SVGElement, images: SVGImageElement[]