Closed bobmitch closed 2 years ago
Fixed by using legacy image serving in core image controller on visitescanaba. https://github.com/HoltBosse/Alba/blob/7d0b2c57c1899154548265b6f77a82114f4140c8/core/controllers/image/controller.php#L13
Need to check performance of both methods - and also investigate using readfile instead of passthru for potential performance gains.
Working on cloudaccess - commented out location header/redirect and exit:
Tested legacy codepath using following method:
$image_count = 1500;
$min_id = 30;
$max_id = 120;
for ($n=0; $n<$image_count; $n++) {
echo "<img class='testimage' src='/image/" . rand($min_id, $max_id) . "/web'>";
}
?>
<style>.testimage {max-width:2rem; height:auto;}</style>
<script>
window.start = performance.now();
var imgList = document.images;
var len = imgList.length;
var imgCounter = 0;
[].forEach.call(imgList, function (img) {
if (img.complete) {
incrementImgCounter();
}
else {
img.addEventListener('load', incrementImgCounter, false);
}
});
function incrementImgCounter() {
imgCounter++;
if (imgCounter === len) {
window.end = performance.now();
console.log('Images loaded in: ', window.end-window.start, 'ms' );
}
}
</script>
Legacy method is on average almost identical to the 'faster' redirect method for around 1500 images. Suspect real-world page differences would be bordering on unmeasurable beyond noise.
Virtual function remains as option, but as yet untested. :)
Legacy file serving path forced here: https://github.com/HoltBosse/Alba/commit/fa7d51552927271e6a94f877c4d0a5c2b347b9b6
Not previewing correctly in Facebook debugger - will test if ok once shared.