Disclaimer - I do not know how to code in PHP or any other language. I'm just an intuitive computer user who can tinker with existing code and make it work for me.
So, I'm working with an existing script in php that I found online. I originally used it to display a random image from a group that I uploaded online. Now, I'm trying to integrate javascript rollover code, into the php. I've succeeded except that it has invalidated the java's ability to preload the rollover image.
Take a look at the following code and tell me if there is a line I can add to have it preload the rollover image:
And a sample piece from the .ini file that lists the images for the php files' use:
As you can see there is some very ugly java splicing involved (done by me) but it works.
I'm hoping there is a way I can add a "lod = mywebpage.comcul/20.jpg" into the .ini and have the php pull that to preload the image. But like I said before, I can't code in php.
So, I'm working with an existing script in php that I found online. I originally used it to display a random image from a group that I uploaded online. Now, I'm trying to integrate javascript rollover code, into the php. I've succeeded except that it has invalidated the java's ability to preload the rollover image.
Take a look at the following code and tell me if there is a line I can add to have it preload the rollover image:
Code:
<?php
/*
Author: Dan Benjamin - [URL]http://hivelogic.com/[/URL]
Copyright (c) 2004 Automatic, Ltd. All Rights Reserved.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF
ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY
IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE OR NONINFRINGEMENT.
IN NO EVENT SHALL DAN BENJAMIN, A LIST APART, OR AUTOMATIC, LTD. BE LIABLE
FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR
LOST PROFITS ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER
ARISING, INCLUDING NEGLIGENCE), EVEN IF DAN BENJAMIN, A LIST APART, OR
AUTOMATIC, LTD. IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES.
*/
# file containg your image descriptions
$IMG_culCONFIG_FILE = 'culimages2.ini';
# You shouldn't need to change anything below this point
function showculImage( $ini=null ) {
global $IMG_culCONFIG_FILE;
# if no custom ini file has been specified, use the default
$ini_file = $ini ? $ini : $IMG_culCONFIG_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" target="_blank" onmouseover="MM_swapImage(%s)" onmouseout="MM_swapImgRestore()">',
$images[$img]['url'],
$images[$img]['rol']
);
}
# output the IMG tag
printf(
'<img src="%s" alt="%s" name="culimg" %s border="0" id="culimg" />',
$images[$img]['src'],
$images[$img]['alt'],
$size[3]
);
# if an url was specified, output the closing A HREF tag
if ( $images[$img]['url'] ) {
echo('</a>');
}
}
?>
Code:
[Cul1]
src = mywebpage.com/cul01.jpg
rol = 'culimg','','mywebpage.comcul/20.jpg',1
alt = Qi Shu Fang Peking Opera
url = [URL]http://www.qishufang.com[/URL]
I'm hoping there is a way I can add a "lod = mywebpage.comcul/20.jpg" into the .ini and have the php pull that to preload the image. But like I said before, I can't code in php.
