|  | Posted by Fred Atkinson on 03/03/07 03:10 
On 2 Mar 2007 14:24:12 -0800, "shimmyshack" <matt.farey@gmail.com>wrote:
 
 >I'm feeling a teeeny bit more generous than Steve, but you have a few
 >basic terminology odds and ends to sort out before people will start
 >"handing you" scripts, as we all know you'll be straight back with "it
 >doesnt uite work" until we've spent far too much time on it, when
 >there are millions of scripts that do this out there already.
 >
 >You need to be structured about this, what are the thumbnails called.
 >If they are random go find a script that can build an array of
 >filesnames from any given directory. That will be 3 or 4 lines long.
 >Hoever if you know they are called thumb_001.jpg thumb_002.jpg then
 >its easier because we know beforehand what's in the subDIRECTORIES
 >(not subpages)
 >
 >then you need to make 2 more arrays,
 >
 >$arrSubDirs = array('bananas','oranges','apples');
 >$arrSubSubDirs = array('aa','bb','cc','dd','ee');
 >this again only works if you know ahead of time what they are and it
 >doesnt keep changing, otherwise the same script that you got to show
 >you a list of files inside a directory can be slightly modified to
 >show only directories, see the manual for examples.
 >
 >next you need to build this into a function, which outputs the html
 >src URL to go into the <img> tag and into the width and height
 >
 >Now how many times are you going to call this function , 5, 10, 20
 >times, it will slow things down, how many files are there in these
 >directories, 100, 1000, 10000000,
 >you want to go in there ONCE and grab a random selection, not repeated
 >go in there and get one each time, (or you might end up with a repeat
 >and have to code for that case...)
 >If yuo have say 100 thumbs go into dir, grab all the thumbs of
 >type .jpg into an array,
 >$arrayThumbDetails['path_and_name'][] = 'the filenames you get';
 >and shuffle() the array, pick out the first however many you might
 >need for your web page, the stat() them to get their width and height,
 >and store them in the same array
 >$arrayThumbDetails['width'][] = 'the width that stat returned';
 >$arrayThumbDetails['height'][] = 'the height that stat returned';
 >
 >
 >your function must therefore take in as values,
 >the sub and subsub folder, the number of images you want back
 >and must return an array of the relative path to the img names with
 >the folders in front (like /orange/aa/thumb_asdd.jpg
 >, widths and heights.
 >so you would do this
 >$arrayImageDetails = getImageDetails('orange','aa',10);
 >
 >Now you have a random array of 10 images with the widths and heights,
 >you just need to get that into html form so you put this in the html
 >
 >
 ><img
 >src="<?php echo array_pop($arrayImageDetails['path_and_name']); ?>"
 >height="<?php echo array_pop($arrayImageDetails['height']); ?>"
 >width="<?php echo array_pop($arrayImageDetails['width']); ?>"
 >alt="<?php echo
 >basename(array_pop($arrayImageDetails['path_and_name'])); ?>"
 >/>
 >
 >for each image, making sure that when you call the function at the top
 >of the page you return at least as many image properties (we called
 >10) as you will need html img tags.
 >
 >now you understand this isnt the most elegant or fast way, its just a
 >way I thought you might understand, if you are a newbie, you could do
 >worse - as steve pointed out graphically - that go get yourself a copy
 >of the downloadable php extended manual for windows (I assume you are
 >a  windows user!) which has other php programmers helpful comments
 >inside, and borrow some of the example code from this manual, good
 >luck.
 
 And you certainly were much more couteous and respectful.
 Thank you.
 
 I wasn't expecting anyone to write all of that though I do
 appreciate it.  I was just hoping someone would know of a free or an
 inexpensive pay script to solve my problem and give me a URL or
 something to find it.
 
 I'll look your coding over.  Maybe I can figure it out well
 enough to code it into my page.  .
 
 Regards, and thanks again,
 
 
 
 Fred
  Navigation: [Reply to this message] |