Page 1 of 1

Thumbnail Gallery

Posted: Tue Oct 10, 2006 9:15 pm
by trent2800
I'm trying to set up a gallery of previous products. I am trying to find out how I would search a directory for files and then display them. Does anyone know a function that would do this?

e.g. In path /www/images/sold/ the script would search the dir for all the images and thumbnails then put in an img tag.

Posted: Tue Oct 10, 2006 9:26 pm
by Luke
glob() maybe?

Posted: Tue Oct 10, 2006 10:09 pm
by trent2800
Yeah, that works, thanks.

Now, how bout this one. My filenames are something like th_123.jpg. How would I get the 123 out of that? I tried substr but it breaks if the id is less or more than 3 chars.

Posted: Tue Oct 10, 2006 11:24 pm
by Burrito

Posted: Wed Oct 11, 2006 12:55 am
by trent2800
that elipsis reeks of sarcasam... I like it.

Posted: Wed Oct 11, 2006 1:16 am
by jmut
trent2800 wrote:that elipsis reeks of sarcasam... I like it.
don't know what "elipsis reeks" is but anyhow :)

Of course it depend on your filenames.

Code: Select all

//e.g with th_123.jpg 

preg_match('#^.*?_(\d+)\.(jpg|png)$#','th_123.jpg',$match);
var_export($match);

//Output
array (
  0 => 'th_123.jpg',
  1 => '123',
  2 => 'jpg',
)

Posted: Wed Oct 11, 2006 1:21 am
by trent2800
Awesome, it works, thanks a lot.


Elipsis: ...

Reeks: to smell to a great degree

So, his '...' was stinky with sarcasam. Thats what I ment.