You can use a userscript to deal with this. This seems to do the job for me:
(function() {
'use strict';
function adjustImage(img, footerWidth) {
const screenHeight = window.innerHeight;
if (img.naturalWidth > footerWidth) {
const scaledHeight = (img.naturalHeight * footerWidth) / img.naturalWidth;
if (scaledHeight > screenHeight) {
img.style.maxHeight = screenHeight + 'px';
img.style.height = '100%';
img.style.width = 'auto';
img.style.objectFit = 'contain';
} else {
img.style.maxWidth = footerWidth + 'px';
img.style.width = '100%';
img.style.height = 'auto';
img.style.objectFit = 'contain';
}
}
}
function setupFooterImages() {
document.querySelectorAll('.attachments.smalltext').forEach(footer => {
const footerWidth = footer.clientWidth;
footer.querySelectorAll('img').forEach(img => {
img.addEventListener('load', () => adjustImage(img, footerWidth));
if (img.complete && img.naturalWidth) {
adjustImage(img, footerWidth);
}
});
});
}
window.addEventListener('load', setupFooterImages);
const observer = new MutationObserver(setupFooterImages);
observer.observe(document.body, { childList: true, subtree: true });
window.addEventListener('resize', setupFooterImages);
})();