June 2009
S M T W T F S
« May   Jul »
 123456
78910111213
14151617181920
21222324252627
282930  

Keeping dynamic header images with WP Super Cache

The WP Super Cache plugin comes highly recommended, especially with the theme that I’m using for my blog layout.   I specifically chose this layout with the intention of caching (because of its high load times), but wanted to keep the dynamic header image.

There are many ways of going about doing the random image selection.  I am retrieving an image based on the images stored in a particular directory.  I used this regex:

if ( preg_match("/(\.gif|\.jpg|\.png)$/", $img_file) ) {
$images[] = $img_file;
}

to retrieve my images, and

$image = file_get_contents($root . $path . “/” . $img);

to retrieve the actual image.  Now WP Super Cache can still serve up a cached page with http://nathanielengelsen.com/headerimage.php always set as the default header image, but headerimage.php can serve up a random dynamic image with every call.

Share:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • HackerNews
  • LinkedIn
  • Reddit
  • Slashdot

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>