« Hey big spender Exclude pingbacks from comments RSS »

Random cuteness

:: Saturday, May 7th 2005 @ 18:37 :: Amadeus, Web design & Coding ::

I made a random header image script for Ami’s site today. The purple ball of yarn photo is still my all time favourite, but Ami is always so cute and cuddly that I wanted to put more images there. The script is very simple:

<?php // Random header image
/* there are 3 pictures to choose from, so number is either 0, 1 or 2 */
$i = rand(0,2);
if ( $i == 0 ) { ?>
  <img src=”<?php bloginfo(’template_directory’); ?>/images/header_01.jpg” alt=”Caramel Ears” />
<?php } else if ( $i == 1 ) { ?>
  <img src=”<?php bloginfo(’template_directory’); ?>/images/set2/header_01.jpg” alt=”Caramel Ears” />
<?php } else if ( $i == 2 ) { ?>
  <img src=”<?php bloginfo(’template_directory’); ?>/images/set3/header_01.jpg” alt=”Caramel Ears” />
<?php } ?>

As there is also the horizontal menu that has part of the image as a background, I had to move that bit of CSS from the style sheet file to the index file:

<div id=”nav” style=”background-image:url(<?php bloginfo(’template_directory’); ?>/images/<?php if ($i == 1) { ?>set2/<?php } else if ($i == 2 ) { ?>set3/<?php } ?>header_02.jpg);”>

That’s a bit crammed but I didn’t want to make it as long and elaborate as for the header image.

Anyway, this post wasn’t about my amazing coding abilities :razz: but the pictures: GO SEE!

No Comments

RSS feed for comments on this post.

No comments yet.

Sorry, the comment form is closed at this time. You can leave a comment here