Skip to content

Commit 3540b73

Browse files
authored
Merge pull request #377 from processing/fix/homepage-alt
Show alt text on homepage images
2 parents b931f57 + 30a100f commit 3540b73

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/components/PageHeader/HomePage.astro

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,28 @@ const { config } = Astro.props;
3232

3333
{
3434
config.data.heroImages.map((im, i) => (
35-
<img
36-
class={`hero-image ${i > 0 ? "hidden" : ""}`}
37-
src={im.image.src}
38-
alt={im.altText}
39-
loading={i > 0 ? "lazy" : "eager"}
40-
/>
35+
<div class={`relative hero-image-container ${i > 0 ? "hidden" : ""}`}>
36+
<img
37+
class={"hero-image"}
38+
src={im.image.src}
39+
alt={im.altText}
40+
loading={i > 0 ? "lazy" : "eager"}
41+
/>
42+
<p
43+
aria-hidden
44+
class={"renderable-alt bg-bg-gray-40 line-clamp-3 absolute top-0 mt-sm mx-sm px-[7.5px] pb-[2.5px] rounded-xl text-body-caption text-ellipsis"}
45+
>
46+
{im.altText}
47+
</p>
48+
</div>
4149
))
4250
}
4351
</div>
4452

4553
<script>
4654
document.addEventListener("DOMContentLoaded", (event) => {
4755
// find all hero image elements
48-
const images = document.querySelectorAll("img.hero-image");
56+
const images = document.querySelectorAll(".hero-image-container");
4957
if (images.length > 1) {
5058
const shownImageInd = Math.round(Math.random() * (images.length - 1));
5159
console.log(shownImageInd);

0 commit comments

Comments
 (0)