Skip to content

Commit b6975ef

Browse files
Add alt attribute to image in <figure> (#276)
1 parent a6ee814 commit b6975ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

view-transitions/spa/script.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function init() {
3737
})
3838

3939
galleryImg.src = `images/${ imageData[0].file }.jpg`;
40+
galleryImg.alt = imageData[0].name;
4041
galleryCaption.textContent = imageData[0].name;
4142
}
4243

@@ -47,6 +48,7 @@ function updateView(event) {
4748
const displayNewImage = () => {
4849
const mainSrc = `${targetIdentifier.src.split("_th.jpg")[0]}.jpg`;
4950
galleryImg.src = mainSrc;
51+
galleryImg.alt = targetIdentifier.alt;
5052
galleryCaption.textContent = targetIdentifier.alt;
5153
};
5254

@@ -60,4 +62,4 @@ function updateView(event) {
6062
const transition = document.startViewTransition(() => displayNewImage());
6163
}
6264

63-
init();
65+
init();

0 commit comments

Comments
 (0)