diff --git a/cache-images.go b/cache-images.go index 26a6e42..16d686e 100644 --- a/cache-images.go +++ b/cache-images.go @@ -511,6 +511,8 @@ func serveMissingImage(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-store, must-revalidate") w.Header().Set("Pragma", "no-cache") w.Header().Set("Expires", "0") - w.WriteHeader(http.StatusNotFound) + if config.DriveCacheEnabled { + w.WriteHeader(http.StatusNotFound) + } http.ServeFile(w, r, missingImagePath) } diff --git a/static/js/dynamicscrollingimages.js b/static/js/dynamicscrollingimages.js index 223017f..6f41285 100644 --- a/static/js/dynamicscrollingimages.js +++ b/static/js/dynamicscrollingimages.js @@ -81,18 +81,23 @@ // Get the img element let img = imageDiv.querySelector('img'); if (img) { + let id = img.getAttribute('data-id'); + if (id) { + imageElements.push(img); + imageIds.push(id); + } if (hardCacheEnabled) { // Replace image with placeholder img.src = '/static/images/placeholder.svg'; img.onerror = function() { handleImageError(img); }; - - let id = img.getAttribute('data-id'); - if (id) { - imageElements.push(img); - imageIds.push(id); - } + } else { + // HardCacheEnabled is false; load images immediately + img.src = img.getAttribute('data-full'); + img.onerror = function() { + handleImageError(img); + }; } } }); @@ -152,12 +157,12 @@ } // Initialize imageElements and imageIds - if (hardCacheEnabled) { - imageElements = Array.from(document.querySelectorAll('img[data-id]')); - imageIds = imageElements - .map(img => img.getAttribute('data-id')) - .filter(id => id); // Exclude empty IDs + imageElements = Array.from(document.querySelectorAll('img[data-id]')); + imageIds = imageElements + .map(img => img.getAttribute('data-id')) + .filter(id => id); // Exclude empty IDs + if (hardCacheEnabled) { // Replace images with placeholders imageElements.forEach(img => { img.src = '/static/images/placeholder.svg'; @@ -166,11 +171,19 @@ // Start checking image status let imageStatusTimer = setInterval(checkImageStatus, imageStatusInterval); checkImageStatus(); // Initial check - - // After initial images are loaded, ensure the page is scrollable - window.addEventListener('load', ensureScrollable); + } else { + // HardCacheEnabled is false; load images immediately + imageElements.forEach(img => { + img.src = img.getAttribute('data-full'); + img.onerror = function() { + handleImageError(img); + }; + }); } + // After initial images are loaded, ensure the page is scrollable + window.addEventListener('load', ensureScrollable); + // Infinite scrolling window.addEventListener('scroll', function() { if (isFetching || noMoreImages) return; diff --git a/templates/images.html b/templates/images.html index bcd05a7..1b48290 100755 --- a/templates/images.html +++ b/templates/images.html @@ -98,11 +98,19 @@
{{ if $.HardCacheEnabled }} - + {{ else }} - - {{ $result.Title }} + + {{ $result.Title }} + + {{ end }}
{{ $result.Width }} × {{ $result.Height }}
diff --git a/templates/images_only.html b/templates/images_only.html index 8183830..ae568f7 100644 --- a/templates/images_only.html +++ b/templates/images_only.html @@ -1,6 +1,20 @@ {{ range $index, $result := .Results }}
{{ if $.HardCacheEnabled }} + + + {{ else }} - - {{ $result.Title }} + + {{ $result.Title }} + + {{ end }}
{{ $result.Width }} × {{ $result.Height }}