diff --git a/assets/ts/gallery.ts b/assets/ts/gallery.ts index b416187..cb1e14a 100644 --- a/assets/ts/gallery.ts +++ b/assets/ts/gallery.ts @@ -93,9 +93,10 @@ class StackGallery { figure.appendChild(el); /// Add figcaption if it exists - if (img.hasAttribute('alt')) { + const childImg = img.querySelector('img') + if (childImg.hasAttribute('alt')) { const figcaption = document.createElement('figcaption'); - figcaption.innerText = img.getAttribute('alt'); + figcaption.innerText = childImg.getAttribute('alt'); figure.appendChild(figcaption); } diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index b2c3a17..028d4f4 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -24,9 +24,6 @@ class="gallery-image" data-flex-grow="{{ div (mul $image.Width 100) $image.Height }}" data-flex-basis="{{ div (mul $image.Width 240) $image.Height }}px" - {{ with $alt }} - alt="{{ . }}" - {{ end }} {{ end }} {{- end -}} @@ -59,6 +56,9 @@ {{ with $Srcset }}srcset="{{ . }}"{{ end }} loading="lazy" decoding="async" + {{ with $alt }} + alt="{{ . }}" + {{ end }} > \ No newline at end of file