Just put the finishing touches on the theme for the gallery associated to my blog (http://sblog.angoulvant.net/). It will probably not be for release unless I get a lot of demand, in which case I would probably adapt the color scheme.
Check it out and tell me what you think:
http://s.angoulvant.net/
The main header takes a random image from the gallery that is cropped using the ZP function, so sometimes it looks great and other times it seems a bit more abstract...
-Stephane
very clean.. I like the random image on the top..
if you search the forums, there is a random image feature that Skwid and I integrated into the Thinkdreams theme. In fact, you can probably grab the whole theme and pick out the custom function from there. It's up on the Wiki.
In the meantime, here is the function I use in my themes:
// 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 1');
$image = new Image(new Album(new Gallery(), $result['folder']), $result['filename']);
return $image;
}
You can use this block of code to display it:
thinkdreams, I did grab your function, right after I posted above, from your theme and it works great, thanks.
However if one wanted to have a bigger image as a random image like in Stephane's theme, all that random image creation will take up some extra server space. Furthermore since its random and cropped depending on the picture it sometime looks weird, depending on the focal point of the picture.
How could the SQL statement in the thinkdreams getRandomImage function be modified to only get album thumbnails randomly instead of any picture in the entire database? That way you could ensure there aren't a ton of extra images being created and that they would look good cropped.
If you look at the zenphoto code, the SQL is not determining the image size the random function displays. The SQL, in any of the zenphoto functions, just retrieves the images from the albums, and then runs them through i.php to create an image, a sized image, or a thumb depending on the function.
Rather, the getsizedimage('120') is what does it. It actually uses the i.php to generate the images, which is what zenphoto is using anyway. So I'm not sure how much more overhead there is for the random function generation, as ALL of the images have to be processed through the i.php at some point anyway. If you're worried about caching space, you may want to consider just sizing your images to a smaller size before uploading to zenphoto, that way you're working with a "display" version of the image. Most of my images don't get uploaded over 1024x768, since anything more than that is quite a bit big for regular web users. You also, for copyright reasons, don't want too high of a resolution....
You can adjust the ('120') to any size you want to change the size of the image you can display. Stephane is probably just adjusting the image size higher for her front page random image. The 120 is what I used to display my random image in the thinkdreams theme.
Sorry I think I didn't explain my self correctly.
I know how to resize the photo. What I'm wondering how to do is restrict the radom image function to only be a subset of all the images in the database. Specifically I only want to display random album thumbnails. So in all the album thumbnails I know they will looked good when cropped to center.
So I believe that it is the SQL statment in the random image function that selects which photos out of the database should be considered. How do I make that SQL statement just find the images that are being used as album thumbnails?