954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

random image script needed

Hi this is my first post. I found this site through the need of a php script for my website. Now I'm not much of a coder, I can just about get by ish.

I have a website www.saltashcameraclub.co.uk I have built this site using E107 mainly because I have used it before and I knew what I was doing. However it doesn't do everything I want.

The script I require needs to be able to generate random images from a top level directory and its sub directories, ( i.e membersimages/member1 membersimages/member2 membersimages/member3) and not only that but I would like to be able to control the height of the image while maintaining the aspect ratio.

Thank you for taking your time to read this and I hope you can help.

edie209
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

The separate parts are probably not that difficult. There are a lot of samples on this site on how to traverse a folder in php. Personally, I use phpThumb for thumbnail sizing and caching. The next problem is probably, what are you going to do with it ? Does it need to become and image slider on your page ? That would mean you'd have to make an e107 plugin of the parts.

pritaeas
Posting Expert
Moderator
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Hi Thanks for the reply,

My idea is to have one random image on a splash page at the beginning of the site, I wanted to draw the random image from the members galleries that way no one person gets favoured

edie209
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Have a look at this: http://php.net/manual/en/function.opendir.php
The examples in the comment show how you can read recursive directory contents. To avoid having to do this everytime someone loads your page, you should cache these results (perhaps in a plain text file), so they can be easily reloaded. You could refresh this file once a day (this all depends on your traffic). H.t.h.

pritaeas
Posting Expert
Moderator
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

thank again for the reply I have been over and had a look and I must admit to feeling a little bit overwhelmed with the information. It might take a little time to work through this.

If I am honest I was hoping to be pointed to a script that just needed a little tweaking as I am just learning the basics of php

edie209
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: