[thelist] PHP image rotating script not working
Bruce Gilbert
webguync at gmail.com
Wed Sep 14 09:25:45 CDT 2005
Hey guys,
I am trying to implement the php image rotating script that is detailed
here at a list apart
http://www.alistapart.com/articles/betterrotator
I can't get it to work though (no rotating).The page I have added the
script to is here:
http://www.inspired-evolution.com/
I *believe* I am doing every thing correctly, so I am puzzled as to why no
rotation.
the php code I am using is
<?php
$IMG_CONFIG_FILE = 'images.ini';
function showImage( $ini=null ) {
global $IMG_CONFIG_FILE;
# if no custom ini file has been specified, use the default
$ini_file = $ini ? $ini : $IMG_CONFIG_FILE;
# read the config file into an array or die trying
$images = @parse_ini_file($ini_file,true);
if (! $images) {
die('Unable to read ini file.');
}
# pick a random image from the parsed config file
$img = array_rand($images);
# get the selected image's css id if one exists
$id = $images[$img]['id'] ?
sprintf( ' id="%s" ', $images[$img]['id'] ) :
'';
# get the selected image's css class if one exists
$class = $images[$img]['class'] ?
sprintf( ' class="%s" ', $images[$img]['class'] ) :
'';
# get selected image's dimensions
$size = @getimagesize( $images[$img]['src'] );
# if an url was specified, output the opening A HREF tag
if ( $images[$img]['url'] ) {
printf(
'<a href="%s" title="%s">',
$images[$img]['url'],
$images[$img]['title']
);
}
# output the IMG tag
printf(
'<img src="%s" alt="%s" %s %s%s/>',
$images[$img]['src'],
$images[$img]['alt'],
$size[3],
$id,
$class
);
# if an url was specified, output the closing A HREF tag
if ( $images[$img]['url'] ) {
echo('</a>');
}
}
?>
with the images listed in the images.ini file. and I am calling it on my
page as such:
<?php require ('rotate.php'); ?><?php showImage () ;?>
the images in the images.ini file are listed exactly as shown in the ALA
article and the ini and rotate.php file are at the same level as my
index.php page with the images in a directory called images.
any *gotchas* that I might be missing to cause this not to work?
TIA
Bruce Gilbert
Inspired-Evolution.com
--
::Bruce::
More information about the thelist
mailing list