If it's just refreshing the content area, and the image (rather, the header area that contains it) is not in the content area, then they won't be refreshed, no. I don't know the details of how that's working, of course, but if there is some way to explain to the CMS that when the content area is refreshed then the header (at least that part of it containing the image) should be refreshed as well then you might have a bit more luck.
One problem I've just noticed is that the 'Location:' header that's generated isn't entirely kosher. It should be a URL, not a file path. If the CMS does anything to rewrite URLs so that they don't match up perfectly with the file system then there could be hazards there: what needs to go in that header should be the same URL that you would use if you were using a conventional image.
On second thought, that header and the corresponding redirection shouldn't even be necessary: you already have the image - why not just give it to them now instead of just asking them to ask for it? Actually I just answered that one for myself: the browser cache. It can cache the images as it gets them. Each time this script is run it gets given the URL to a random image. If it's one it hasn't seen before it downloads it and displays it; otherwise it can fetch the cached version and avoid requesting it again.
So on third thought the redirection ought to remain. Unless the CMS is doing some weird voodoo that changes the HTTP response code for the output of this script then the browser cache will be normal. The URL given in the Location really ought to be fixed, though.
Anyway; in light of all that I thought I'd do a rewrite just to see what I get:
<?php
$folder = '';
$exts = 'jpg,jpeg,png,gif'; // Notice the commas
if('' == $folder) $folder = './';
$files = glob($folder.'{'.$exts.'}', GLOB_BRACE);
$image = $files[array_rand($files)];
//From http://www.php.net/header
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$url = "http://$host$uri/$image";
header("Location: $url");
?>
<html><body><a href="<?php echo $url?>"><?php echo basename($image);?></a></body></html>