Random Image Theme

Random Image is a theme for WordPress 1.5 or later, based on the default Kubrick theme, modified to display random header images. It also features a horizontal menu listing all available pages and supports Google AdSense. If you have an AdSense account, simply paste your AdSense account into adsense.php. The current version supports Sidebar Widgets.

You can download the Random Image theme here. Download the PhotoShop template for graphics here.

Modifying the theme

Here’s how it works if you’d like to modify the theme.
The random image is generated by this piece of PHP code in header.php:

<?php
function header_graphic() {
	echo "/images/";
	$num=rand(0,10);
	echo "kubrickheader".$num.".jpg";
};
?>

The function ‘rand(0,10)’ will cause it to generate an image file name from ‘kubrickheader0.jpg’ through ‘kubrickheader10.jpg’. If you have a different number of images, change those numbers.

Make sure you place all of your image files in the /images/ subdirectory of the theme with the correct names. For best results, use the Photoshop template to create those images and insure they’re the proper size.

The image is actually displayed by several CSS entries and a DIV tag in header.php. This CSS entry picks the image to display and specifies it as the background image:

#header { background: url("<?php bloginfo('stylesheet_directory'); header_graphic(); ?>") no-repeat bottom center; }

The following CSS entries specify the size & position of the image:

#header 	{ margin: 0; padding: 1px; height: 198px; width: 758px; }
#headerimg 	{ margin: 7px 9px 0; height: 192px; width: 740px; }

Finally, the following bit of HTML displays the header graphic and adds the title:

<div id=header>
<h1>
<a href="<?php echo get_settings('home'); ?>"><?php bloginfo('name'); ?></a>
</h1>

7 responses to “Random Image Theme

  1. Pingback: Mark Turner - A Life, Unfinished

  2. Pingback: /dev/random › Page not found

  3. Pingback: Art La Flamme » Blog Archive » Photos for use with Wordpress Themes

  4. Pingback: Art La Flamme » Blog Archive » Photos for use with Wordpress Themes

  5. I just updated Random Image because it says it now supports the new sidebars in 2.0, but according to my wp-admin pages, sidebars are not supported by this theme.

    Is there something I need to do to enable this?

  6. I would love to modify this somehow to add a left sidebar as well. I love the look of the theme and the ability to do the random images, but my right sidebar is just way too full now. lol Any ideas?

  7. I just modified Unique Picture because it says it now facilitates the new sidebars in 2.0, but according to my wp-admin webpages, sidebars are not reinforced by this concept.

Leave a Reply