Skip to content

Commit a5363fb

Browse files
hugopeeklubber-de
andauthored
feat(embed): add optional alt tag to placeholder
This is desirable for web use. When no alt value is provided, the alt tag will not be shown (same as current behaviour). Co-authored-by: Marco 'Lubber' Wienkoop <[email protected]>
1 parent 18b5554 commit a5363fb

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/definitions/modules/embed.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@
119119

120120
createPlaceholder: function (placeholder) {
121121
var
122-
icon = module.get.icon()
122+
icon = module.get.icon(),
123+
alt = module.get.alt()
123124
;
124125
placeholder = placeholder || module.get.placeholder();
125-
$module.html(templates.placeholder(placeholder, icon));
126-
module.debug('Creating placeholder for embed', placeholder, icon);
126+
$module.html(templates.placeholder(placeholder, icon, alt));
127+
module.debug('Creating placeholder for embed', placeholder, icon, alt);
127128
},
128129

129130
createEmbed: function (url) {
@@ -203,6 +204,9 @@
203204
placeholder: function () {
204205
return settings.placeholder || $module.data(metadata.placeholder);
205206
},
207+
alt: function () {
208+
return settings.alt || $module.data(metadata.alt);
209+
},
206210
icon: function () {
207211
return settings.icon || ($module.data(metadata.icon) !== undefined
208212
? $module.data(metadata.icon)
@@ -288,6 +292,7 @@
288292
.removeData(metadata.id)
289293
.removeData(metadata.icon)
290294
.removeData(metadata.placeholder)
295+
.removeData(metadata.alt)
291296
.removeData(metadata.source)
292297
.removeData(metadata.url)
293298
;
@@ -557,6 +562,8 @@
557562
source: false,
558563
url: false,
559564
id: false,
565+
placeholder: false,
566+
alt: false,
560567

561568
// standard video settings
562569
autoplay: 'auto',
@@ -579,6 +586,7 @@
579586
id: 'id',
580587
icon: 'icon',
581588
placeholder: 'placeholder',
589+
alt: 'alt',
582590
source: 'source',
583591
url: 'url',
584592
},
@@ -654,7 +662,7 @@
654662
+ ' width="100%" height="100%"'
655663
+ ' msallowFullScreen allowFullScreen></iframe>';
656664
},
657-
placeholder: function (image, icon) {
665+
placeholder: function (image, icon, alt) {
658666
var
659667
html = '',
660668
deQuote = $.fn.embed.settings.templates.deQuote
@@ -663,7 +671,7 @@
663671
html += '<i class="' + deQuote(icon) + ' icon"></i>';
664672
}
665673
if (image) {
666-
html += '<img class="placeholder" src="' + deQuote(image) + '">';
674+
html += '<img class="placeholder" src="' + deQuote(image) + (alt ? '" alt="' + deQuote(alt) : '') + '">';
667675
}
668676

669677
return html;

0 commit comments

Comments
 (0)