1
HFS ~ HTTP File Server / Re: how to inline images in folder view
« on: August 01, 2024, 03:35:45 PM »
Could try the thumbnails plugin: https://github.com/rejetto/thumbnails
But I don't really trust the author, looks like a shady fellow.
So I wrote this custom-html-footer code:
- half-joking, I need to be able to specify max-width, made a feature request here https://github.com/rejetto/thumbnails/issues/3
But I don't really trust the author, looks like a shady fellow.
So I wrote this custom-html-footer code:
Code: [Select]
(function () {
// todo: is there an event fired by HFS when all elements are loaded? that would be better than this retry approach.
let retryUntilSuccessFunction;
retryUntilSuccessFunction = function () {
let images = document.querySelectorAll('span[role="img"].fa-image');
if (images.length === 0) {
setTimeout(retryUntilSuccessFunction, 100);
return;
}
document.querySelectorAll('span[role="img"].fa-image').forEach(function (el) {
let span = el;
while (el.tagName.toLocaleLowerCase() !== 'a') {
el = el.parentNode;
}
let url = el.href;
let imageElement = document.createElement('img');
imageElement.src = url;
imageElement.style['max-width'] = '500px';
span.appendChild(imageElement);
});
};
retryUntilSuccessFunction();
})();
- half-joking, I need to be able to specify max-width, made a feature request here https://github.com/rejetto/thumbnails/issues/3