Zophar's Message Domain

Go Back   Zophar's Message Domain > General Chat > Tech Talk

Reply
 
Thread Tools Display Modes
Old 06-27-2005, 05:34 PM   #1
Audigy
Senior Member
 
Audigy's Avatar
 
Join Date: Apr 2004
Location: Houston, TX
Posts: 755
Default 'Display all images on one page' possible with PHP?

Hi,

I'm looking for a script that will take a directory of images and display them on a page, one after the other, just a constant stream of 'img src=' tags.

That, or just the PHP syntax to read all image files from a directory and plop them into a table of some kind... I just want to avoid having to write an html page to display thousands of images, hehe.

I figure it involves reading from a directory and just running some loop that goes until it's displayed all the images in the directory. I have no idea how to write PHP though, I can only do idiot things like modify existing code.

I've Googled around for scripts like this, but I haven't found one that simply spits out all the images in a folder onto a page... it wants to do complicated things like make thumbnails and stuff.

Thanks.
__________________
http://www.oddigy.com
Audigy is offline   Reply With Quote
Old 06-27-2005, 06:00 PM   #2
Audigy
Senior Member
 
Audigy's Avatar
 
Join Date: Apr 2004
Location: Houston, TX
Posts: 755
Default Re: 'Display all images on one page' possible with PHP?

oi, I really hope someone here helps me out... I got an ICQ from some guy from another site who says

"how about we bargain a deal, I give you the code and any sprites you rip you submit to (site name removed) eh?"

which... is definitely not my intention. I'm looking for script for my site, not a bargain with some guy to submit all the sprites I rip to his site, hrmph. :P

but yeah, that's my goal here.. i have a folder sitting around with thousands of sprites that i've ripped, and am continually adding to it. I'd like to be able to just display them all on an html page without writing img tags for each one.
<img src=smilies/retard.gif>
__________________
http://www.oddigy.com
Audigy is offline   Reply With Quote
Old 06-27-2005, 06:02 PM   #3
SwampGas
Senior Member
 
Join Date: Apr 2000
Posts: 6,915
Default Re: 'Display all images on one page' possible with PHP?

Well, since I AM a http://zend.com/zce.php?c=ZEND002157&r=211670282Zend Certified Engineer</a>, I suppose I can type something up in the next 30 seconds.....and begin.

html body
?php

if ($fp = opendir('/file/path')) {
while (false !== ($file = readdir($fp))) {
if ($file == '.' || $file == '..' || !preg_match('/^.*\.(jpg|gif|png)$/i',$file)) continue;
echo "img src=\"{$file}\" br / br / \n";
}
closedir($fp);
}
/html

Fill in the greater/less than since zmd can't handle that.
SwampGas is offline   Reply With Quote
Old 06-27-2005, 06:04 PM   #4
Gavin_86
Senior Member
 
Join Date: Aug 2002
Posts: 1,082
Default Re: 'Display all images on one page' possible with PHP?

http://zophar.net/personal/Gavin/gallery.php.txtscript</a>
http://zophar.net/personal/Gavin/index.php.txtusage</a>

http://zophar.net/personal/Gavin/working example</a>

whipped that up. it's short but it works. edit the html as you see fit.

edit: oops. forgot var is deprecated, and the formatting was fucked.<P ID="edit"><FONT class="small">Edited by Gavin_86 on 06/27/05 02:08 PM.</FONT></P>
Gavin_86 is offline   Reply With Quote
Old 06-27-2005, 06:10 PM   #5
Gavin_86
Senior Member
 
Join Date: Aug 2002
Posts: 1,082
Default Re: 'Display all images on one page' possible with PHP?

oh, touche. i guess that's why i'm not a Zend Certified Engineer <img src=smilies/cwm11.gif>
Gavin_86 is offline   Reply With Quote
Old 06-27-2005, 06:12 PM   #6
SwampGas
Senior Member
 
Join Date: Apr 2000
Posts: 6,915
Default Re: 'Display all images on one page' possible with PHP?

What the HELL are creating a class for? <img src=smilies/eek13.gif>
SwampGas is offline   Reply With Quote
Old 06-27-2005, 06:13 PM   #7
SwampGas
Senior Member
 
Join Date: Apr 2000
Posts: 6,915
Default Re: 'Display all images on one page' possible with PHP?

> oh, touche. i guess that's why i'm not a Zend Certified
> Engineer

No, you just did a whole lotta work for a whole lotta nothing. Don't use classes unless you really need OOP because it slows everything down. Only reason you'd need OOP instead of functions is if you require constructors, inheritence, etc.
SwampGas is offline   Reply With Quote
Old 06-27-2005, 06:16 PM   #8
Gavin_86
Senior Member
 
Join Date: Aug 2002
Posts: 1,082
Default Re: 'Display all images on one page' possible with PHP?

> What the HELL are creating a class for?

well, it was originally code i was using for a larger image gallery script and because i'm a lazy jerk i just cut this portion out and stripped a few other things.
Gavin_86 is offline   Reply With Quote
Old 06-27-2005, 06:53 PM   #9
Audigy
Senior Member
 
Audigy's Avatar
 
Join Date: Apr 2004
Location: Houston, TX
Posts: 755
Default Re: 'Display all images on one page' possible with PHP?

Awesome awesome, thank you.
Now... uh... do I need to edit any of that stuff? I tried it as it is and got

Warning: opendir(): open_basedir restriction in effect. File(/file/path) is not within the allowed path(s): (/home/oddigy/:/usr/lib/php:/usr/local/lib/php:/tmp)

... ;_;
Stupid webserver. Are there any workarounds, or am I pretty much screwed?
__________________
http://www.oddigy.com
Audigy is offline   Reply With Quote
Old 06-27-2005, 06:55 PM   #10
Audigy
Senior Member
 
Audigy's Avatar
 
Join Date: Apr 2004
Location: Houston, TX
Posts: 755
Default Re: 'Display all images on one page' possible with PHP?

ok, i'll try yours next... unless my directory problem will screw this up too, hehe.
*examines*

> whipped that up. it's short but it works. edit the html as
> you see fit.
__________________
http://www.oddigy.com
Audigy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:56 PM.

Contact Us - Zophar's Domain - Archive - Top

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.