|
Posted by Steve on 03/03/07 18:38
"shimmyshack" <matt.farey@gmail.com> wrote in message
news:1172945967.893113.300330@t69g2000cwt.googlegroups.com...
| On 3 Mar, 15:20, Fred Atkinson <fatkin...@mishmash.com> wrote:
| > Folks,
| >
| > I found another script that does the job. It needs a little
| > tweaking, but the code is simple enough that I can do that without too
| > much trouble.
| >
| > The script I found is
at:http://www.theprojects.org/scripts/Get_Image_List/in case you'd like
| > to have a look at it.
| >
| > Regards,
| >
| > Fred
|
| as you modify it, try to think of how efficient it will be, if I were
| you and I wanted to call this script many times in a webpage, I would
| definately build the array, and thin it down to the humber of images
| you need in yout page, then stat the images, and also use its "return
| the array of images" option, but extend the array to add the width and
| height and alt, then you will have excatly what I was on about before.
| The reason why returning an array is a good idea, is that you read the
| dir once, and then have the details of the all the images. Then when
| you put these details into the html, your users will request each in
| turn and the server will go get each. This way you dont hit the disk
| so much. If you have a great many images, You should split them as you
| seem to have done, by directory to improve response time.
| If all that seems little boring, welcome to programming where you do
| well to think of every tiny thing, it is a good habit to get into. Of
| course there are a few problems with this approach - not the least of
| which is returning an array of a set number of images (because its
| faster) but perhaps adjusting your html later to include more images.
| For this reason you might like to call the function many times
| returning on one each time, but on a very busy system this makes
| things slow and also this kind of habit decreases the life of your
| hard disk. zzZ
yes, and we haven't even gotten into random selection before even
knowing/careing about what is on the hd...or other functions that are less
hd intensive than enumerating a dir before it actually has to happen...or
talked about using require/include/require_once/include_once to selectively
perform the function on demand...or, how to use oop to apply logic to
accessing the data and giving some sort of caching mechanism for the info of
a dir per session. a myriad of other things...then again, he just wanted a
hand-out of code that required the least amount of work for him to
implement...yet still run despite his great propensity to break things
during the process.
;^)
Navigation:
[Reply to this message]
|