Welcome to Geeklog, Anonymous Tuesday, March 19 2024 @ 01:32 am EDT

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.

You can download the script here :
http://wwww.chmouel.org/misc/lib-custom.html

Or see a preview on :
http://www.chmouel.org

 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.
 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. Smile keep up the good work!
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Has anyone been able to intergrate the Gallery random image script and Geeklog?
In a world without walls and fences, who needs Windows and Gates?
 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.

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.
 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?
 Quote

Anonymous

Anonymous
Where do I need to put the code for the gallery hack?
 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;
 Quote

All times are EDT. The time is now 01:32 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