fix(stage.ts, collection.ts, gallery.ts, resources.ts): set the alt attribute of the image element to the value of the alt property in the ImageJSON object to improve accessibility and provide alternative text for images.

This commit is contained in:
Sped0n
2023-11-03 09:55:32 +08:00
parent 5c69862832
commit 8caf13e5d5
4 changed files with 4 additions and 3 deletions

View File

@@ -267,7 +267,7 @@ function createStage(ijs: ImageJSON[]): void {
e.dataset.loUrl = ij.loUrl
e.dataset.loImgH = ij.loImgH.toString()
e.dataset.loImgW = ij.loImgW.toString()
e.alt = 'image'
e.alt = ij.alt
stage.append(e)
}
container.append(stage)

View File

@@ -86,7 +86,7 @@ function createCollection(ijs: ImageJSON[]): void {
e.dataset.src = ij.loUrl
e.height = ij.loImgH
e.width = ij.loImgW
e.alt = 'image'
e.alt = ij.alt
e.style.transform = `translate3d(${x}%, ${y - 50}%, 0)`
_collection.append(e)
}

View File

@@ -195,7 +195,7 @@ function createGallery(ijs: ImageJSON[]): void {
e.dataset.src = ij.hiUrl
e.height = ij.hiImgH
e.width = ij.hiImgW
e.alt = 'image'
e.alt = ij.alt
// append
_swiperSlide.append(e)
_swiperWrapper.append(_swiperSlide)

View File

@@ -1,6 +1,7 @@
// data structure for images info
export interface ImageJSON {
index: number
alt: string
loUrl: string
loImgH: number
loImgW: number