aboutsummaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
authorStephen Kraus <8003332+stephenmk@users.noreply.github.com>2023-12-22 19:17:17 -0600
committerGitHub <noreply@github.com>2023-12-23 01:17:17 +0000
commit93cdbe4b718f9f7a2cd0d6efc545ec51d049812f (patch)
treefd5026b3ed4432a98d361063e13084139edb4e81 /ext/js
parentc18141a09b519a8ea650874aa09c06d7fa4fb98d (diff)
Add support for alt attribute on structured content images (#359)
* Add support for alt attribute on structured content images * Add new `alt` property for structured content images * Update test script with new media file count --------- Co-authored-by: stephenmk <stephenmk@users.noreply.github.com>
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/display/sandbox/structured-content-generator.js3
-rw-r--r--ext/js/language/dictionary-importer.js2
2 files changed, 4 insertions, 1 deletions
diff --git a/ext/js/display/sandbox/structured-content-generator.js b/ext/js/display/sandbox/structured-content-generator.js
index a28464ae..ad63667a 100644
--- a/ext/js/display/sandbox/structured-content-generator.js
+++ b/ext/js/display/sandbox/structured-content-generator.js
@@ -65,6 +65,7 @@ export class StructuredContentGenerator {
preferredWidth,
preferredHeight,
title,
+ alt,
pixelated,
imageRendering,
appearance,
@@ -102,7 +103,7 @@ export class StructuredContentGenerator {
imageContainer.appendChild(imageBackground);
const image = /** @type {HTMLImageElement} */ (this._createElement('img', 'gloss-image'));
- image.alt = '';
+ image.alt = typeof alt === 'string' ? alt : '';
imageContainer.appendChild(image);
const overlay = this._createElement('span', 'gloss-image-container-overlay');
diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js
index 2b9792ea..2c0c7e9c 100644
--- a/ext/js/language/dictionary-importer.js
+++ b/ext/js/language/dictionary-importer.js
@@ -503,6 +503,7 @@ export class DictionaryImporter {
width: preferredWidth,
height: preferredHeight,
title,
+ alt,
description,
pixelated,
imageRendering,
@@ -518,6 +519,7 @@ export class DictionaryImporter {
if (typeof preferredWidth === 'number') { target.preferredWidth = preferredWidth; }
if (typeof preferredHeight === 'number') { target.preferredHeight = preferredHeight; }
if (typeof title === 'string') { target.title = title; }
+ if (typeof alt === 'string') { target.alt = alt; }
if (typeof description === 'string') { target.description = description; }
if (typeof pixelated === 'boolean') { target.pixelated = pixelated; }
if (typeof imageRendering === 'string') { target.imageRendering = imageRendering; }