Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 10:50 am EST
Geeklog Forums
Random Images
Status: offline
chmouel
Forum User
Newbie
Registered: 02/05/02
Posts: 13
Hi,
This is a Block i use to get random images displayed from a gallery. Inspiration come mainly from existing blocks i saw on this site.
This is a Block i use to get random images displayed from a gallery. Inspiration come mainly from existing blocks i saw on this site.
You can download the script here :
http://wwww.chmouel.org/misc/lib-custom.html
Or see a preview on :
http://www.chmouel.org
16
15
Quote
Status: offline
Tony
Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
This didn't quite work for me. I did hack it a bit to get it to work but the use of srand() and rand() brought my webserver to it's knees.
Turns out the built in PHP randomizer does a poor job and in many cases returns a bogus values which is really causing me problems. I tried switching to mt_srand() and mt_rand() with similar results. Anybody else have a way to do this. As it stands you would have to do a while loop until mt_rand() returns a valid value. I'll admit, I haven't complete read the PHP docs on this but if anyone has input let me konw.
-----
The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
11
12
Quote
Status: offline
dreamscape
Forum User
Junior
Registered: 01/22/02
Posts: 30
that's great. i'm glad people are finally starting to code and share phpblocks for GL.
keep up the good work!
15
11
Quote
Status: offline
Tony
Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
I do have the code that compliments the work on the Geeklog/Gallery integration.
The reason people blame things on previous generations is that there's only one other choice.
You can get the two functions from here
NOTE: this code does not work well if you have albums with no pictures in it. You'll need to change the code to handle that if you have such a case (e.g. such as nothing but sub-albums in an album)
See it in action here
----- The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
12
13
Quote
Status: offline
squatty
Forum User
Full Member
Registered: 01/21/02
Posts: 269
Thanks! That's exactly what I was looking for. I created my own hack for Gallery but my version wasn't smart enough to link back inside the album. You the man!
In a world without walls and fences, who needs Windows and Gates?
In a world without walls and fences, who needs Windows and Gates?
12
12
Quote
Anonymous
Anonymous
Where do I need to put the code for the gallery hack?
12
20
Quote
Status: offline
efarmboy
Forum User
Moderator
Registered: 02/26/02
Posts: 147
Thanks Tony,
Copied the new functions into my GL lib-custom file and made a few edits on the $gallery variables, added the defines to my geeklog/config.php file and was up an running.
I further made a quick hack to not look at a private album and filter out empty albums. Made changes to the function phpblock_random_files($g)
I think you can see the changes below:
// Randomly select one of the images if index counter > 2
// Anthing < is an empty album or only the highlight image
// If the album is completely empty, setting the index to 1 will show a empty image but no errors
if ($index > 2) {
mt_srand((double)microtime()*1000000);
$indexr = (mt_rand(1, count($pics)));
} else {
$indexr = 1;
18
27
Quote
All times are EST. The time is now 10:50 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content