diff --git a/cache-images.go b/cache-images.go index 22d507c..8c4e55e 100644 --- a/cache-images.go +++ b/cache-images.go @@ -273,6 +273,7 @@ func handleImageServe(w http.ResponseWriter, r *http.Request) { resp, err := http.Get(imageURL) if err != nil { printWarn("Error fetching image: %v", err) + recordInvalidImageID(imageID) serveMissingImage(w, r) return } @@ -311,7 +312,18 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) { continue } - // Check for cached full or thumbnail images + // Check if the image ID is marked as invalid + invalidImageIDsMu.Lock() + _, isInvalid := invalidImageIDs[id] + invalidImageIDsMu.Unlock() + + if isInvalid { + // Image is invalid; inform the frontend by setting the missing image URL + statusMap[id] = "/static/images/missing.svg" + continue + } + + // Existing code to check for cached images extensions := []string{"webp", "svg"} // Extensions without leading dots imageReady := false @@ -341,15 +353,13 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) { } } - // If neither is ready + // If neither is ready and image is not invalid if !imageReady { if !config.DriveCacheEnabled { // Hard cache is disabled; use the proxy URL statusMap[id] = fmt.Sprintf("/image/%s_thumb", id) - } else { - // Hard cache is enabled; image is not yet cached - // Do not set statusMap[id]; the frontend will keep checking } + // Else, do not set statusMap[id]; the frontend will keep checking } } diff --git a/static/css/style.css b/static/css/style.css index 9fe92a3..29c8eb9 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -263,7 +263,7 @@ html { .image { flex-grow: 1; - padding: .5rem .5rem 3rem .5rem; + padding: .5rem .5rem 2rem .5rem; margin: .25rem; border: 1px solid #00000000; border-radius: 12px; @@ -311,8 +311,7 @@ html { box-shadow: 0 14px 28px var(--view-image-color); } -.img_title, -.img_source { +.img_title { display: block; position: absolute; width: 100%; @@ -328,11 +327,6 @@ html { color: var(--blue); } -.img_source { - padding: 1.8rem 0 0 0; - font-size: .7rem; -} - .image img { margin: 0; padding: 0; @@ -726,6 +720,7 @@ hr { background: var(--html-bg); cursor: pointer; transition: all .3s ease; + text-align: left; } .torrent-cat:hover, diff --git a/templates/images.html b/templates/images.html index a4516fb..62819ee 100755 --- a/templates/images.html +++ b/templates/images.html @@ -116,7 +116,6 @@
{{ $result.Width }} × {{ $result.Height }}
{{ $result.Title }} - {{ translate "source" }}
{{ end }} diff --git a/templates/images_only.html b/templates/images_only.html index e51dbe6..2e3aa18 100644 --- a/templates/images_only.html +++ b/templates/images_only.html @@ -1,12 +1,6 @@ {{ range $index, $result := .Results }}
{{ if $.HardCacheEnabled }} - - - {{ $result.Width }} × {{ $result.Height }}
{{ $result.Title }} - {{ translate "source" }}
{{ end }}