Skip to content

Commit 6e55e82

Browse files
committed
feat(thumbnails): add alt tag for thumbnails if availabe
1 parent adf847d commit 6e55e82

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/plugins/thumbnail/lg-thumbnail.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export default class Thumbnail {
406406
return thumbDragUtils;
407407
}
408408

409-
getThumbHtml(thumb: string, index: number): string {
409+
getThumbHtml(thumb: string, index: number, alt?: string): string {
410410
const slideVideoInfo =
411411
this.core.galleryItems[index].__slideVideoInfo || {};
412412
let thumbImg;
@@ -426,21 +426,23 @@ export default class Thumbnail {
426426
thumbImg = thumb;
427427
}
428428

429+
const altAttr = alt ? 'alt="' + alt + '"' : '';
430+
429431
return `<div data-lg-item-id="${index}" class="lg-thumb-item ${
430432
index === this.core.index ? ' active' : ''
431-
}"
433+
}"
432434
style="width:${this.settings.thumbWidth}px; height: ${
433435
this.settings.thumbHeight
434436
};
435437
margin-right: ${this.settings.thumbMargin}px;">
436-
<img data-lg-item-id="${index}" src="${thumbImg}" />
438+
<img ${altAttr} data-lg-item-id="${index}" src="${thumbImg}" />
437439
</div>`;
438440
}
439441

440442
getThumbItemHtml(items: ThumbnailGalleryItem[]): string {
441443
let thumbList = '';
442444
for (let i = 0; i < items.length; i++) {
443-
thumbList += this.getThumbHtml(items[i].thumb, i);
445+
thumbList += this.getThumbHtml(items[i].thumb, i, items[i].alt);
444446
}
445447

446448
return thumbList;

0 commit comments

Comments
 (0)