Need a PHP or Javascript delay for IMG
<p>I need something to help with my local production of some IMG loaders that I made with jQuery. They work fine on the web after I empty my browser's cache but local testing is just too fast to see the loading animation while the image is downloading.</p>

<p>So what I need is something to delay the IMG from loading for a specified amount of time. Not just a timeout function on the img loaders I made.</p>

<p>Maybe something like this to delay the img load for 5 seconds. Something in PHP would probably be preferred, I'm not sure. Any help greatly appreciated.</p>

<pre><code>&lt;img src="photo.jpg?delay5" /&gt;
</code></pre>

<p>@Jamund and @Brad both answered this correctly. I added my own take to make the script a bit leaner with the help of the built-in function GETIMAGESIZE :</p>

<p>The HTML</p>

<pre><code>&lt;!-- HTML--&gt;
&lt;a href="idelay.php?file=poster.jpg"&gt;&lt;img src="th_poster.jpg"  width="100" /&gt;&lt;/a&gt;
</code></pre>

<p>The PHP</p>

<pre><code>&lt;?php 
// contents of idelay.php (image delay)
$file = $_GET['file'];
$absolutePath = 'http://demos.lap/assets/photos/celebrities/';
$imginfo = getimagesize($absolutePath.$file);
$mimeinfo = $imginfo['mime']; //without curly braces if not calling directly such as in this variable

//header("Content-type: {$imginfo['mime']}");
header("Content-type: $mimeinfo");
sleep(5);
readfile($absolutePath.$file);

?&gt;
</code></pre>
