From 4df4d76f5ae877f790b85804bc4f6d794e9e3f94 Mon Sep 17 00:00:00 2001 From: Clara Rigaud Date: Sat, 21 Sep 2024 07:39:56 +0200 Subject: [PATCH] a11y --- assets/js/theme/components/lightbox/container.js | 11 +++++++---- .../partials/commons/lightbox/lightbox-container.html | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/assets/js/theme/components/lightbox/container.js b/assets/js/theme/components/lightbox/container.js index 5ec705d56..48822f973 100644 --- a/assets/js/theme/components/lightbox/container.js +++ b/assets/js/theme/components/lightbox/container.js @@ -28,13 +28,16 @@ window.osuny.lightbox.LightboxContainer.prototype = { }, show (lightbox) { this._removeImageContent(); - this._setImageContent(lightbox.url); + this._setImageContent(lightbox); // maybe add description ou alt this.content.focus(); }, - _setImageContent (url) { + _setImageContent (lightbox) { var image = document.createElement('img'); - image.setAttribute('src', url); + image.setAttribute('src', lightbox.url); + if (lightbox.description) { + image.setAttribute('alt', lightbox.description); + } this.content.append(image); }, _removeImageContent () { @@ -48,7 +51,7 @@ window.osuny.lightbox.LightboxContainer.prototype = { this.footerElement.inert = true; this.footerElement.setAttribute('aria-hidden', 'true'); }, - _enablePageElement() { + _enablePageElement () { this.mainElement.inert = false; this.mainElement.setAttribute('aria-hidden', 'false'); this.headerElement.inert = false; diff --git a/layouts/partials/commons/lightbox/lightbox-container.html b/layouts/partials/commons/lightbox/lightbox-container.html index f6375eea8..4e2f9dc39 100644 --- a/layouts/partials/commons/lightbox/lightbox-container.html +++ b/layouts/partials/commons/lightbox/lightbox-container.html @@ -1,6 +1,6 @@