Problem using Zenphoto as a plugin

I am using Zenphoto as a plugin by including the template-functions.php file. I can return random images from an album but I find that some images will be returned twice.

I would prefer unique images being returned and only landscape ones. I figure I could run a query directly on the database and then use the Image class to create the image object but it gives me a Fatal Error saying "lass 'Image' not found". Should I be using a different approach?

Here is my code:
`
$album = 'folder name of album';
$result= $query_full_array('SELECT i.filename, i.title, a.folder FROM '.prefix('images').' as i INNER JOIN '.prefix('albums').' as a ON i.albumid = a.id where a.folder="'.$album.'" and i.width > i.height ORDER BY RAND() LIMIT 10');
for ($i=0; $i < sizeof($result); $i++) {
$image = new Image(new Album(new Gallery(), $result[$i]['folder']), $result[$i]['filename']);
$title[] = $image->getTitle();
}
`

Comments

  • acrylian Administrator, Developer
    You should use the `newImage()` function and not the class constructor (as noted on the object model tutorial and I think even the doc)
Sign In or Register to comment.