From 01c48fd36636b14ee7af854166d40bad8b33f159 Mon Sep 17 00:00:00 2001 From: partisan Date: Wed, 13 Nov 2024 17:49:02 +0100 Subject: [PATCH] hopefully fixed 'missing.svg' in image results --- images.go | 12 +++++++++++- templates/images.html | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/images.go b/images.go index 5ffcb46..6743060 100755 --- a/images.go +++ b/images.go @@ -217,10 +217,20 @@ func fetchImageResults(query, safe, lang string, page int, synchronous bool) []I } } + // Filter out images that failed to cache or are invalid + validResults := make([]ImageSearchResult, 0, len(results)) + for _, imageResult := range results { + if imageResult.ProxyFull != "" { + validResults = append(validResults, imageResult) + } else { + printWarn("Skipping invalid image with ID %s", imageResult.ID) + } + } + // Final debug print to show the count of results fetched printInfo("Fetched %d image results for overall page %d", len(results), page) - return results + return validResults } func wrapImageSearchFunc(f func(string, string, string, int) ([]ImageSearchResult, time.Duration, error)) func(string, string, string, int) ([]SearchResult, time.Duration, error) { diff --git a/templates/images.html b/templates/images.html index bb39283..646772a 100755 --- a/templates/images.html +++ b/templates/images.html @@ -240,7 +240,7 @@