Subject: Random Images

Posted on: 05/02/02 06:12am
By: chmouel

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 :

Or see a preview on :

Doesn't work...

Posted on: 05/02/02 08:53pm
By: Tony

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.

very cool

Posted on: 06/02/02 05:15am
By: dreamscape

that's great. i'm glad people are finally starting to code and share phpblocks for GL. Smile keep up the good work!

Ramdom Image & Gallery

Posted on: 06/02/02 08:11am
By: squatty

Has anyone been able to intergrate the Gallery random image script and Geeklog?

Geeklog/Gallery Random Pics

Posted on: 06/02/02 11:29am
By: Tony

I do have the code that compliments the work on the Geeklog/Gallery integration.

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.

Geeklog/Gallery Random Pics

Posted on: 06/02/02 09:10pm
By: squatty

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!

Where does the code go?

Posted on: 05/03/02 04:51pm
By: Anonymous

Where do I need to put the code for the gallery hack?

Geeklog/Gallery Random Pics

Posted on: 21/03/02 02:42pm
By: efarmboy

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;

Geeklog - Forum