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
Comments
Very nice !
Lovely pictures too ...
As for your validating problem, i think it might be possible to fix by using html entities rather than just the character.
(Example: "&" instead of "&")
Thanks!
Just asking.. coz i like to try this on my zen.
please....
// 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:
<?php
$randomImage = getRandomImages();
$randomImageURL = getURL($randomImage);
print "<center>getTitle()."'><img src='".$randomImage->getSizedImage('120')."' alt='".$randomImage->getTitle()."'></center>";
?>
Check it out!
-Stephane
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.
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.
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?
The thumbnails are no more than processed i.php images. So the procedure is as follows:
1. SQL Query is made based on album and image
2. Thumbnail or regular sized image?
3. If Thumb, run through i.php and convert to thumb.
4. If Image, run through i.php and convert (if necessary)
5. Display.
Thus, resizing the photo happens after the SQL query. The database doesn't actually contain any thumbnails. The i.php takes the image from the DB and converts it to whatever size was asked for after the SQL query.
So, if you want to display only random thumbnails, then you need to size and crop the image as a thumb. There are a couple custom thumb functions in the template-functions.php you should be able to use to do a custom thumb and crop size.
Now, if you want to only randomize based on certain albums, then you will need to change the SQL query to include only those albums you want to gather to randomize. However, the SQL query will then need to be run through i.php.
This is hopefully what you were looking for, but if anyone else has any more suggestions, that would be cool too.
.prefix("album").'.thumb
to the select statement. Bear in mind my syntax may be off. Anyone else want to comment?
`function getRandomImage() {
$result = query_single_row('SELECT folder,thumb FROM '.prefix("albums").' ORDER BY RAND() LIMIT 1');
$image = new Image(new Album(new Gallery(), $result['folder']), $result['thumb']);
return $image;
}`