Hi,
I have a site where I have a number of folders containing images. For each folder I want to display a random image on the homepage.
I have got it working but I am not sure if it is done in the best way possible.
Basically I load all the image file names in the folder into an array, pick one at random and then output img tags for the random image. Is there any better way of doing this?
Each time I load up the page the images seem to always take a bit longer to download than id like. This could just be down to the image size but they are all thumbnails so it shouldn't be an issue.
Is there any way that the list of images could be cached on the server and then a random one picked each time? I'm thinking maybe the delay for images loading is due to the processing involved to pick an image but I could be wrong.
I'm happy with the script I have but if it could be done in a better way i'd be keen to know.
I'm also looking to build a search function to search images by descriptions etc. Again would this be best to load all images with matching descriptions into an array and then output the img tags as necessary?
Sorry if this isn't explained well but would appreciate any input from the php pros on this!
Thanks
I have a site where I have a number of folders containing images. For each folder I want to display a random image on the homepage.
I have got it working but I am not sure if it is done in the best way possible.
Basically I load all the image file names in the folder into an array, pick one at random and then output img tags for the random image. Is there any better way of doing this?
Each time I load up the page the images seem to always take a bit longer to download than id like. This could just be down to the image size but they are all thumbnails so it shouldn't be an issue.
Is there any way that the list of images could be cached on the server and then a random one picked each time? I'm thinking maybe the delay for images loading is due to the processing involved to pick an image but I could be wrong.
I'm happy with the script I have but if it could be done in a better way i'd be keen to know.
I'm also looking to build a search function to search images by descriptions etc. Again would this be best to load all images with matching descriptions into an array and then output the img tags as necessary?
Sorry if this isn't explained well but would appreciate any input from the php pros on this!
Thanks