I have as site that uses zenphoto as photo-album. On my frontpage of my site (not the album) do i want a random photo from a certain album from zenphoto.
I found this code on the site but I have no idea how to implement this:
`
@readfile(’http://www.ksaizegem.be/zenphoto/zp-core/random.php?
num=9&height=50&width=50&class=one-image’)`
Can you help me with this?
Comments
1.First, you have to create a file called random.php in your zp-core directory containing something like that :
`
<?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 = '';
isset($_REQUEST['height']) ? $height = $_REQUEST['height'] : $height = '';
isset($_REQUEST['class']) ? $class = $_REQUEST['class'] : $class = '';
isset($_REQUEST['album']) ? $album = $_REQUEST['album'] : $album = '';
/*MODIF NICO */
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 . '">' .
"getSizedImage(getOption('image_size')) . "' alt=\"random image - \n" . $randomImage->getTitle() .'" />';
$num--;
}
?>
`
2.Then paste that :
`<?php @readfile('http://yourwebsiteIP/~yourusername/zenphoto/zp-core/random.php?num=1&class=one-image&album=the-name-of-your-certain-album.alb') ?>`
at the place you want the photo to be displayed on your frontpage .php page.
Note : I used it to display an image from a virtual album.
Good luck.