In the process of switching servers. I'm 95% there but having an issue with my random image script.
It works perfectly on my production server - I upgraded the production site to 1.4.4.8 before copying everything to the new server. When I went to the new server I installed 1.4.5 not realizing a newer version was released the next day.
Anyway, I haven't switched production to 1.4.5 so I'm not sure if it's a version issue or a server issue - or something else...
This is the script I'm using:
<?php
@readfile('
http://test.mikemartinelli.com/zp-core/random2.php?num=1&height=150&width=200&album=My-Car-Pics/Capri.alb')?>
It's built to pull a random image from a dynamic gallery based on tags...
If you past that link in the browser and load it - it loads a random image so I know it's working...but when it's on the site nothing displays...no error just no image.
The random.php script:
<?php
/*******************************************************************************
* random.php: return random image
*******************************************************************************
* URL Parameters:
* num - number of images
* width - width of random image.
* height - height of random image.
* class - css class for random image.
* album - album to get the random image, default is root.
*
*******************************************************************************
*/
define('OFFSET_PATH', true);
require_once("template-functions.php");
isset($_REQUEST['num']) ? $num = $_REQUEST['num'] : $num = 0;
isset($_REQUEST['width']) ? $width = $_REQUEST['width'] : $width = 50;
isset($_REQUEST['height']) ? $height = $_REQUEST['height'] : $height = 50;
isset($_REQUEST['cwidth']) ? $cropw = $_REQUEST['cwidth'] : $cropw = 200;
isset($_REQUEST['cheight']) ? $croph = $_REQUEST['cheight'] : $croph = 150;
isset($_REQUEST['class']) ? $class = $_REQUEST['class'] : $class = '';
isset($_REQUEST['album']) ? $album = $_REQUEST['album'] : $album = '';
header ('Content-Type: text/html; charset=' . getOption('charset'));
while ($num > 0) {
if ($album == '') {
$randomImage = getRandomImages();
} else {
$randomImage = getRandomImagesAlbum($album);
}
$randomImageURL = getURL($randomImage);
echo '
getTitle() . '" class="' . $class . '">' .
'<img border="0" src="' . getMainSiteURL() . $randomImage->getCustomImage(null, $width, $height, $cropw, $croph, null, null, null, null) .
'" width="' . $width . '" height="' . $height . '" alt="'.$randomImage->getTitle().'"';
echo "/>\n";
$num--;
}
?>
Any ideas?
Thanks,
Mike
Comments
There is a random image function which does not support tags though.
I got the @readfile code from here:
http://www.zenphoto.org/news/random-image-for-external-site
and I got the random.php file from this site too...
`
<?php @readfile('http://test.mikemartinelli.com/zp-core/random2.php?num=1&height=150&width=200&album=My-Car-Pics/Capri.alb')
?>
`
`
<?php
/*******************************************************************************
* random.php: return random image
*******************************************************************************
* URL Parameters:
* num - number of images
* width - width of random image.
* height - height of random image.
* class - css class for random image.
* album - album to get the random image, default is root.
*
*******************************************************************************
*/
define('OFFSET_PATH', true);
require_once("template-functions.php");
isset($_REQUEST['num']) ? $num = $_REQUEST['num'] : $num = 0;
isset($_REQUEST['width']) ? $width = $_REQUEST['width'] : $width = 50;
isset($_REQUEST['height']) ? $height = $_REQUEST['height'] : $height = 50;
isset($_REQUEST['cwidth']) ? $cropw = $_REQUEST['cwidth'] : $cropw = 200;
isset($_REQUEST['cheight']) ? $croph = $_REQUEST['cheight'] : $croph = 150;
isset($_REQUEST['class']) ? $class = $_REQUEST['class'] : $class = '';
isset($_REQUEST['album']) ? $album = $_REQUEST['album'] : $album = '';
header ('Content-Type: text/html; charset=' . getOption('charset'));
while ($num > 0) {
if ($album == '') {
$randomImage = getRandomImages();
} else {
$randomImage = getRandomImagesAlbum($album);
}
$randomImageURL = getURL($randomImage);
echo 'getTitle() . '" class="' . $class . '">' .
'getCustomImage(null, $width, $height, $cropw, $croph, null, null, null, null) .
'" width="' . $width . '" height="' . $height . '" alt="'.$randomImage->getTitle().'"';
echo "/>\n";
$num--;
}
?>
`
I'm open to other options though...
I mis-spoke earlier...not using tags to display images...the virtual gallery is create based on tags...this random file references the virtual gallery.
For theme use, your simplest solution is to create a dynamic album from the tags and get random images from that album via the `getRandomImageAlbum()` that acrylian mentions.
In the meantime I've used the getrandomimageAlbum() function to accomplish what I want.
This pulls a random image from a dynamic gallery (gallery based on tags) and displays the image, with link, sized to 200px wide.
`
<?php $randomImage = getRandomImagesAlbum("My-Design-Work/Design.alb"); $randomImageURL = getURL($randomImage); print "<a href='".getURL($randomImage)."' title='".$randomImage->getTitle()."'>getSizedImage('200')."' alt='".$randomImage->getTitle()."' />"; ?>
`