mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 07:17:12 +03:00
Change image alt text in viewer to indicate when images are loading, and when loading fails
Related to #79
This commit is contained in:
parent
f7bfe052ca
commit
59129ba20a
@ -128,12 +128,12 @@ const DISCORD = (function() {
|
||||
|
||||
// noinspection HtmlUnknownTarget
|
||||
templateEmbedImage = new TEMPLATE([
|
||||
"<a href='{url}' class='embed thumbnail'><img src='{src}' alt='(image attachment not found)'></a><br>"
|
||||
"<a href='{url}' class='embed thumbnail'><img src='{src}' alt='(image attachment is loading...)' onerror='DISCORD.handleImageLoadError(this)'></a><br>"
|
||||
].join(""));
|
||||
|
||||
// noinspection HtmlUnknownTarget
|
||||
templateEmbedImageWithSize = new TEMPLATE([
|
||||
"<a href='{url}' class='embed thumbnail'><img src='{src}' width='{width}' height='{height}' alt='(image attachment not found)'></a><br>"
|
||||
"<a href='{url}' class='embed thumbnail'><img src='{src}' width='{width}' height='{height}' alt='(image attachment is loading...)' onerror='DISCORD.handleImageLoadError(this)'></a><br>"
|
||||
].join(""));
|
||||
|
||||
// noinspection HtmlUnknownTarget
|
||||
@ -164,6 +164,12 @@ const DISCORD = (function() {
|
||||
].join(""));
|
||||
},
|
||||
|
||||
handleImageLoadError(ele) {
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
ele.onerror = null;
|
||||
ele.setAttribute("alt", "(image attachment not found)");
|
||||
},
|
||||
|
||||
isImageAttachment(attachment) {
|
||||
const dot = attachment.url.lastIndexOf(".");
|
||||
const ext = dot === -1 ? "" : attachment.url.substring(dot).toLowerCase();
|
||||
|
Loading…
x
Reference in New Issue
Block a user