From 5877ad94636dbecec16dac3b073513566249e565 Mon Sep 17 00:00:00 2001 From: Eva Date: Mon, 22 May 2023 09:29:56 +0200 Subject: [PATCH] client/posts: display thumbnail while original image is loading --- client/js/controls/post_content_control.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client/js/controls/post_content_control.js b/client/js/controls/post_content_control.js index 55daca76..aca907b0 100644 --- a/client/js/controls/post_content_control.js +++ b/client/js/controls/post_content_control.js @@ -119,7 +119,18 @@ class PostContentControl { post: this._post, autoplay: settings.get().autoplayVideos, }); - if (settings.get().transparencyGrid) { + if (["image", "flash"].includes(this._post.type)) { + newNode.style.backgroundImage = "url("+this._post.thumbnailUrl+")"; + } + if (this._post.type == "image") { + newNode.firstElementChild.addEventListener("load", (e) => { + if (settings.get().transparencyGrid) { + newNode.classList.add("transparency-grid"); + } else { + newNode.style.backgroundImage = ""; + } + }); + } else if (settings.get().transparencyGrid) { newNode.classList.add("transparency-grid"); } if (this._postContentNode) {