Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
My php question of the week... display multiple random images

I'm using Zenphoto on a mate's blog... going along nicely but there's not much help forthcoming from its forum

Can anyone help me to tweak this code - I've made a few changes to just show 1 image on my homepage - but I need another version of it to display 4 small images in my sidebar - all I can get it to do is show 4 version of the same image... any ideas?
I understand how the function works , but no idea how to loop it, or make it more oop or whatever you call it...

Can anyone help me to tweak this code - I've made a few changes to just show 1 image on my homepage - but I need another version of it to display 4 small images in my sidebar - all I can get it to do is show 4 version of the same image... any ideas?
I understand how the function works , but no idea how to loop it, or make it more oop or whatever you call it...
<!-- small random image -->
<?php
require_once('portfolio/zen/classes.php');
$zpimagesize = (isset($_GET['s']) ? $_GET['s'] : 95);
$randomImage = getRandomImage();
$imageLinkURL = getImageLinkURL($randomImage);
$imagesrc = $randomImage->getSizedImage($zpimagesize);
$imagesrc = substr($imagesrc, 1);
$imagesrc = "http://www.paulryding.com/portfolio" . $imagesrc;
print "<a href='http:".$imageLinkURL."' alt='".$randomImage->getTitle()."'><img src='".$imagesrc."' class='mainimage' alt='".$randomImage->getTitle()."'></a>";
function getRandomImage() {
global $_zp_current_image;
if(db_connect()) {
$random=query_single_row('SELECT zpimages.filename, zpimages.title, zpalbums.folder FROM zpimages INNER JOIN zpalbums ON zpimages.albumid = zpalbums.id ORDER BY RAND() LIMIT 1');
$image = new Image(new Album(new Gallery(), $random['folder']), $random['filename']);
return $image;
} else {
return false;
}
}
function getImageLinkURL($image) {
return WEBPATH . "/www.paulryding.com/portfolio/" . urlencode($image->getAlbumName()) . "/" . urlencode($image->name);
}
?>
0
This discussion has been closed.
Comments
This is the second time I've bolted Zenphoto onto Wordpress and it's getting easier - just need to combine the 2 admin panels now haha...
The inline text editing (Flickr style) is pretty impressive!
(is your name meant to read like something else?)