I concocted a bit of jquery and php to preload images from an image folder. Our site has since grown and all portfolio images have been put in different folders within the main image directory. I need a way to preload these to make our portfolio quicker. Below is what I have so far.
It loops through the images and puts them into a hidden div so they get cached.
inside preload.php
<div style="display:none">
<?php
$dirf = 'images';
$dir = scandir($dirf);
foreach($dir as $file) {
if(($file!='..') && ($file!='.')) {
echo "<img src='images/$file' />";
}
}
?>
</div>
I use a bit of jquery to put it on the page via the #preload div and get rid of it afterwards
$('#preload').load('preload.php', function () {
$('#preload').remove();
});