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 @@