From 8c3f0c3d527d8d33295abf576d443570c1d03a29 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 29 Nov 2024 16:57:28 +0100 Subject: [fix] if image load fails on client side, show default image BTW: change icon color from red to gray Closes: - https://github.com/searxng/searxng/issues/4066 Signed-off-by: Markus Heiser --- searx/static/themes/simple/src/js/main/results.js | 9 +++++---- searx/static/themes/simple/svg4web.svgo.js | 1 - src/brand/img_load_error.svg | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/searx/static/themes/simple/src/js/main/results.js b/searx/static/themes/simple/src/js/main/results.js index 7342f94b2..5e3f8ed40 100644 --- a/searx/static/themes/simple/src/js/main/results.js +++ b/searx/static/themes/simple/src/js/main/results.js @@ -7,13 +7,14 @@ } searxng.ready(function () { - d.querySelectorAll('#urls img.image').forEach( + d.querySelectorAll('#urls img').forEach( img => img.addEventListener( 'error', () => { - img.style.display = 'none'; - img.error = null; - } + // console.log("ERROR can't load: " + img.src); + img.src = window.searxng.settings.theme_static_path + "/img/img_load_error.svg"; + }, + {once: true} )); if (d.querySelector('#search_url button#copy_url')) { diff --git a/searx/static/themes/simple/svg4web.svgo.js b/searx/static/themes/simple/svg4web.svgo.js index 83f74cde1..5e12251f3 100644 --- a/searx/static/themes/simple/svg4web.svgo.js +++ b/searx/static/themes/simple/svg4web.svgo.js @@ -14,6 +14,5 @@ module.exports = { 'sortAttrs', // Optimize SVG for WEB usage 'convertStyleToAttrs', - 'removeXMLNS' ], }; diff --git a/src/brand/img_load_error.svg b/src/brand/img_load_error.svg index 4bd867c5c..63aa86ec0 100644 --- a/src/brand/img_load_error.svg +++ b/src/brand/img_load_error.svg @@ -50,17 +50,17 @@