Files
the-monospace-web-pandoc/index.js
Oskar Wickström c88ee9ac50 support images
2024-08-22 17:13:19 +02:00

13 lines
319 B
JavaScript

// Set the ratio variable on each image.
document.querySelectorAll("img").forEach(img => {
function onLoaded() {
const ratio = img.naturalWidth / img.naturalHeight;
img.style.setProperty("--ratio", ratio);
}
if (img.loaded) {
onLoaded();
} else {
img.addEventListener("load", onLoaded);
}
});