mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-14 07:37:13 +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
|
// noinspection HtmlUnknownTarget
|
||||||
templateEmbedImage = new TEMPLATE([
|
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(""));
|
].join(""));
|
||||||
|
|
||||||
// noinspection HtmlUnknownTarget
|
// noinspection HtmlUnknownTarget
|
||||||
templateEmbedImageWithSize = new TEMPLATE([
|
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(""));
|
].join(""));
|
||||||
|
|
||||||
// noinspection HtmlUnknownTarget
|
// noinspection HtmlUnknownTarget
|
||||||
@ -164,6 +164,12 @@ const DISCORD = (function() {
|
|||||||
].join(""));
|
].join(""));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleImageLoadError(ele) {
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
ele.onerror = null;
|
||||||
|
ele.setAttribute("alt", "(image attachment not found)");
|
||||||
|
},
|
||||||
|
|
||||||
isImageAttachment(attachment) {
|
isImageAttachment(attachment) {
|
||||||
const dot = attachment.url.lastIndexOf(".");
|
const dot = attachment.url.lastIndexOf(".");
|
||||||
const ext = dot === -1 ? "" : attachment.url.substring(dot).toLowerCase();
|
const ext = dot === -1 ? "" : attachment.url.substring(dot).toLowerCase();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user