Member
Member
Phoonix   2009-04-01, 12:10
#1
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?
Member
Member
flu   2009-04-01, 13:34
#2
I don't know if it still works with the new release (as I stopped using this random photo script for months) but here is the way I used it (which is not necessarily the best way to proceed, maybe there is a new function in ZP to do that) :

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 . '">' .
"<img src='".$randomImage->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.
Member
Member
Phoonix   2009-04-01, 16:15
#3
Thank you, your script works fine for me.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.