I am trying to display several random images without the same image repeating.
is it possible that I could change the current Random Image Function included in the Effervenscence to do this?
`
// Get Random Images function getRandomImages() {$result = query_single_row('SELECT '.prefix("images").'.filename,'.prefix("images").'.title, '.prefix("albums").'.folder FROM '.prefix("images").' INNER JOIN '.prefix("albums").' ON '.prefix("images").'.albumid = '.prefix("albums").'.id ORDER BY RAND() LIMIT 2');$image = new Image(new Album(new Gallery(), $result['folder']), $result['filename']);return $image;}function getURL($image) {if (zp_conf('mod_rewrite')){return WEBPATH . "/" . pathurlencode($image->getAlbumName()) . "/" . urlencode($image->name);}else{return WEBPATH . "/index.php?album=" . pathurlencode($image->getAlbumName()) . "&image=" . urlencode($image->name);}}
`
-Raz88
Comments
Example, This is what is showing up now:
http://www.example.com/blog/gallery/test/
this is what I want:
http://www.example.com/blog/gallery/test/image.jpg
-Raz88
What version of zenphoto are you running?
Would zenphoto in its latest SVN version present any differences to this function? I'm trying to figure out why the same function works differently across a couple installations (and themes). I hadn't noticed before that it was directing the URL to the album, not the image, so it seems to be "truncating" the image portion of the URL, even though the image displays correctly. So the DB query is OK, might be something that is wrong in the getURL function that is causing trouble.
Could you take a peek and see if something is amiss? I can't figure out what's causing it.
`function getRandomImages() {
$result = query_single_row('SELECT '.prefix("images").'.filename,'.prefix("images").'.title, '.prefix("albums").'.folder FROM '.prefix("images").' INNER JOIN '.prefix("albums").' ON '.prefix("images").'.albumid = '.prefix("albums").'.id ORDER BY RAND() LIMIT 1');
$image = new Image(new Album(new Gallery(), $result['folder']), $result['filename']);
return $image;
}
function getURL($image) {
if (zp_conf('mod_rewrite'))
{
return WEBPATH . "/" . pathurlencode($image->getAlbumName()) . "/" . urlencode($image->name);
}
else
{
return WEBPATH . "/index.php?album=" . pathurlencode($image->getAlbumName()) . "&image=" . urlencode($image->name);
}
}
`
anyway, replace the getURL code with this in your customfunctions.php file:
(Note the use of `$image->getFileName()` instead)
`function getURL($image) {
if (zp_conf('mod_rewrite'))
{
return WEBPATH . "/" . pathurlencode($image->getAlbumName()) . "/" . urlencode($image->getFileName());
}
else
{
return WEBPATH . "/index.php?album=" . urlencode($image->getAlbumName()) . "&image=" . urlencode($image->getFileName());
}
}`
Let me know how it works for you. It seems to work OK on Bushwood now. (http://www.bushwoodworking.com)
-Raz88
No computer random function will be 100% completely random due to the nature of computers and random numbers, so that is my best guess on how it may work.
Other programmers on the board may have other ideas to provide on how it may work more efficiently.