From 5e1d4edd87cd4c0fbd42af0c1a6bdbcfba7698a5 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 19 Aug 2020 13:02:09 -0400 Subject: [PATCH 1/3] Set background color on blurhash image load --- src/components/images/imageLoader.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/images/imageLoader.js b/src/components/images/imageLoader.js index 39dc6c2622..3dc91ffa91 100644 --- a/src/components/images/imageLoader.js +++ b/src/components/images/imageLoader.js @@ -87,6 +87,7 @@ import 'css!./style'; requestAnimationFrame(() => { if (elem.tagName !== 'IMG') { elem.style.backgroundImage = "url('" + url + "')"; + elem.style.backgroundColor = '#fff'; } else { elem.setAttribute('src', url); } @@ -108,6 +109,7 @@ import 'css!./style'; if (elem.tagName !== 'IMG') { url = elem.style.backgroundImage.slice(4, -1).replace(/"/g, ''); elem.style.backgroundImage = 'none'; + elem.style.backgroundColor = null; } else { url = elem.getAttribute('src'); elem.setAttribute('src', ''); From e5198a6328d9880e30776fcb72af3d6a09a8872e Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 19 Aug 2020 13:36:29 -0400 Subject: [PATCH 2/3] Skip adding background color for non-blurhashable items --- src/components/images/imageLoader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/images/imageLoader.js b/src/components/images/imageLoader.js index 3dc91ffa91..17ec55d7ac 100644 --- a/src/components/images/imageLoader.js +++ b/src/components/images/imageLoader.js @@ -87,7 +87,9 @@ import 'css!./style'; requestAnimationFrame(() => { if (elem.tagName !== 'IMG') { elem.style.backgroundImage = "url('" + url + "')"; - elem.style.backgroundColor = '#fff'; + if (!elem.classList.contains('non-blurhashable')) { + elem.style.backgroundColor = '#fff'; + } } else { elem.setAttribute('src', url); } From f4a329433efe9c0cca5bd0b694cc586386620566 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 19 Aug 2020 13:47:16 -0400 Subject: [PATCH 3/3] Only add background color to blurhashed items --- src/components/images/imageLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/images/imageLoader.js b/src/components/images/imageLoader.js index 17ec55d7ac..b0ffecd64f 100644 --- a/src/components/images/imageLoader.js +++ b/src/components/images/imageLoader.js @@ -87,7 +87,7 @@ import 'css!./style'; requestAnimationFrame(() => { if (elem.tagName !== 'IMG') { elem.style.backgroundImage = "url('" + url + "')"; - if (!elem.classList.contains('non-blurhashable')) { + if (elem.classList.contains('blurhashed')) { elem.style.backgroundColor = '#fff'; } } else {