The drawback that I see in this is that there will be a loading period for the new image, and because of this, the animation can be a little bizarre. It may be useful to have two parts in this file where the path is returned if $ _GET is equal to one thing, and the image is returned if this $ _GET is not set or it is equal to something else. This way you can preload a series of images and there will be smoother animation between the images.
Having said that, it seems to me that something like this should work.
$(document).ready(function(){ function swapImage(){ var time = new Date(); $('#image').fadeOut(1000) .attr('src', 'http://mydomain.com/images/rotate.php?'+time.getTime()) .fadeIn(1000); } var imageInterval = setInterval('swapImage()',10*1000); });
Time makes the browser think that it is getting a new image.
spacer.gif
To do this with a black spacer, I would recommend wrapping the image in a div and giving the background color of the div # 000 according to the separator:
#image-wrap{background-color:#000;}
This would make the image really fade to black instead of fading with the current background color, changing to black and fading again. js will be very similar to the above:
function swapImage(){ var time = new Date(); $('#image').fadeOut(1000) .attr('src', 'http://mydomain.com/spacer.gif') .attr('src', 'http://mydomain.com/images/rotate.php?'+time.getTime()) .fadeIn(1000); } var imageInterval = setInterval('swapImage()',10*1000);
Saving time there is probably not necessary, but, hey, this is another defense against the browser caching the "image".
source share