Member
Member
sceilig   2010-08-07, 06:53
#1

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:
&#36;album = 'folder name of album'; &#36;result= &#36;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="'.&#36;album.'" and i.width > i.height ORDER BY RAND() LIMIT 10'); for (&#36;i=0; &#36;i < sizeof(&#36;result); &#36;i++) { &#36;image = new Image(new Album(new Gallery(), &#36;result[&#36;i]['folder']), &#36;result[&#36;i]['filename']); &#36;title[] = &#36;image->getTitle(); }

Administrator
Administrator
acrylian   2010-08-07, 09:56
#2

You should use the newImage() function and not the class constructor (as noted on the object model tutorial and I think even the doc)

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.