export function initCaseNaturalImagesHalfSize() { const images = Array.from( document.querySelectorAll(".case-media--natural img") ).filter((img) => !img.closest(".case-media-slider")); if (!images.length) return; function applyHalfSize(img) { const naturalWidth = img.naturalWidth || 0; if (!naturalWidth) return; const halfWidth = Math.max(1, Math.round(naturalWidth / 2)); img.style.width = `${halfWidth}px`; img.style.maxWidth = "100%"; } images.forEach((img) => { if (img.complete && img.naturalWidth > 0) { applyHalfSize(img); return; } img.addEventListener("load", () => applyHalfSize(img), { once: true }); }); }