From 85cb039426fffab419764da3546fbc9a602ab3f7 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 7 Feb 2018 17:40:15 +0200 Subject: [PATCH] Still render link previews if image fails to load --- client/js/renderPreview.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index a6cb01a9..5cc8ae80 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -27,6 +27,15 @@ function renderPreview(preview, msg) { // If there is an image in preview, wait for it to load before appending it to DOM // This is done to prevent problems keeping scroll to the bottom while images load image.on("load", () => appendPreview(preview, msg, template)); + + // If the image fails to load, remove it from DOM and still render the preview + if (preview.type === "link") { + image.on("abort error", () => { + image.parent().remove(); + + appendPreview(preview, msg, template); + }); + } } function appendPreview(preview, msg, template) {