fixed invalid links on images when DriveCache was disabled
Some checks failed
Run Integration Tests / test (push) Failing after 21s
Some checks failed
Run Integration Tests / test (push) Failing after 21s
This commit is contained in:
parent
b6c37452ca
commit
6c351c5f2b
4 changed files with 101 additions and 22 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue