Portrait pictures only
|
phgrove
Joined: 2002-10-10
Posts: 101 |
Posted: Sun, 2003-05-18 14:06
|
|
i am trying to alter the random-block code such that it will only display portrait pictures. I have added the following line sof code in on the random-blocvk code but i get some errors. if (isset($index)) {
$id = $album->getPhotoId($index);
list($iWidth, $iHeight) = $album->getThumbDimensions($id);
echo "width = $iWidth\n";
echo "hieght = $iHeight\n";
echo ""
."<a href=" .makeAlbumUrl($album->fields["name"], $id) .">"
.$album->getThumbnailTag($index)
."</a>";
$caption = $album->getCaption($index);
A demo of the code can be seen at http://www.petergrove.co.uk/index2.php Peter |
|

Posts: 3474
Well, you should probably add a new flag, say, $isPortrait or something, and set it to FALSE. Then put the code in a while() loop:
$isPortrait = FALSE; while (!$isPortrait) { $album = chooseAlbum(); if ($album) { $index = choosePhoto($album); } if (isset($index)) { [...] code to test dimensions, resize image, print [...] } [...] }-Beckett (
)
Posts: 101
Thanks beckett! The main problem i have is i am not sure how i get the dimension of the image usign the code already inthe gallery program. Once i get the dimension the rest i can do quite easily. Any chance you might be able to give me some pointers on this.
Peter
Posts: 3474
Well... you're right so far in using the *thumbnail* dimensions rather than the image dimensions, because you could have a portrait image but have the thumbnail cropped to be a landscape.
What you have above, using getThumbDimensions() is definitely the way to go. What problems are you having with it? It seems to list them just fine.
-Beckett (
)
Posts: 101
If you keep refreshing the page [url]www.peterrgove.co.uk/index2.php [/url] you will find you eventually some error like this :-
Any idea's?
Thanks
Peter
Posts: 3474
Sounds like the error which can be fixed by changing this line:
$choose = rand(1, $count);to
$choose = rand(1, (int) $count);-Beckett (
)
Posts: 101
Fixed it by using the code
instead of
Silly mistake.
Now all i need to finds out is how you resize an image on the fly to fit a cretain cell in a table, or is this better done on the clients machine.
Peter