/dev/random

Reality has a liberal bias

/dev/random random header image

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>

4 Comments

4 responses so far ↓

  • 1 Mark Turner - A Life, Unfinished // Nov 30, 1999 at 12:00 am

    links from Technorati I’ve chosen a new theme for MT.Net: Random Image! It randomly rotates the photo on the banner, so it should keep things interesting. I will soon stock it with my own photos. I hope to take some shots of Raleigh landmarks to add to the rotation but I have surprisingly few of those at the moment.

  • 2 /dev/random › Page not found // Feb 5, 2008 at 7:45 pm

    links from TechnoratiHomeAboutArchivesContactFlickr PhotosMore LinksProjectsMii TransferRandom Image ThemeWidgets

  • 3 Art La Flamme &raquo; Blog Archive &raquo; Photos for use with Wordpress Themes // May 11, 2008 at 2:24 pm

    [...] He and I both use Wordpress. He and I made a trip to the Alps last weekend. He and I both took a ton of photos. He uses the Mandigo theme; I use Kubrick variant, Random Photo. [...]

  • 4 Mark // Jul 2, 2008 at 11:21 pm

    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?

Leave a Comment

retaggr