php forum
php mysql forum
php mysql smarty
 
Topic Options
#283041 - 01/11/05 09:02 PM Question about this code...
DrChaos Offline
Coder

Registered: 09/12/03
Posts: 816
Loc: Hollywood Florida.
This is a script that will show the images in a folder as thumbnails and when you click the thumbnails it will open the original image. The thing im tring to get it to do is when the thumbnail is clicked it will open the image in a new window not the same one. I would also like to add the "close this window" link too. Ill never be able to afford PhotoPost so this is what i have to use. If you take this code and call it index.php and place it into a folder with images you can see what it does.<br /><br /><br /><br />
Code:
&lt;?<br />if( ! isset( $filename ) ){<br />define( "SIZE" , 120 ) ;<br />define( "COLNUM" , 5 ) ;<br />$dir = ($dir)?$dir:"." ;<br />?&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Our Pictures &lt;?= $dir ?&gt;&lt;/title&gt;<br />&lt;style type="text/css"&gt;<br />&lt;!--<br />table{<br />width:100%;<br />}<br />td{<br />text-align:center;<br />}<br />img{<br />border:none;<br />}<br />--&gt;<br />&lt;/style&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;table&gt;<br />&lt;?<br />$dd = opendir($dir) ;<br /><br />for( $i = 0 ; $filename = readdir($dd) ; ){<br />if( is_file("$dir/$filename") ){<br />if( $imgSize = getImageSize("$dir/$filename") ){<br /><br />$w0 = $imgSize[0] ;<br />$h0 = $imgSize[1] ;<br /><br />$imgType = $imgSize[2] ;<br /><br />$ratio = $w0 / $h0 ;<br /><br />if( $ratio &gt; 1 ){<br />$w1 = SIZE ;<br />$h1 = ( SIZE * $h0 ) / $w0 ;<br />}<br />else{<br />$w1 = ( SIZE * $w0 ) / $h0 ;<br />$h1 = SIZE ;<br />}<br /><br />$params = sprintf( "filename=$dir/$filename&amp;w0=$w0&amp;h0=$h0&amp;imgType=$imgType&amp;h1=%d&amp;w1=%d" , $h1 , $w1 ) ;<br /><br />if( ! ( $i % COLNUM ) ){<br />echo "\n&lt;tr&gt;\n" ;<br />}<br />?&gt;<br />&lt;td&gt;<br />&lt;a href="&lt;?= "$dir/$filename" ?&gt;"&gt;<br />&lt;img src="&lt;?= $filename ?&gt;?&lt;?= $params ?&gt;" style="width:&lt;?= $w1 ?&gt;;height:&lt;?= $h1 ?&gt;;"&gt;&lt;/a&gt;&lt;br&gt;<br />&lt;?= "$filename : $w0 x $h0" ?&gt;<br />&lt;?<br />$i++ ;<br />}<br />}<br />}<br />?&gt;<br />&lt;/table&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br />&lt;?<br />closedir($dd) ;<br />}<br />else{<br />switch($imgType){<br />case 1:<br />$imgType = "gif" ;<br />break;<br /><br />case 2:<br />$imgType = "JPEG" ;<br />break;<br /><br />case 3:<br />$imgType = "png" ;<br />break;<br /><br />default:<br />break;<br />}<br />header("Content-type: image/$imgType") ;<br /><br />$tImg = imageCreate( $w1 , $h1 ) ;<br /><br />$imgOpenFunc = "imageCreateFrom".$imgType ;<br />$imgSendFunc = "image".$imgType ;<br /><br />$img = $imgOpenFunc("$filename") ;<br /><br />imageCopyResized( $tImg , $img , 0 , 0 , 0 , 0 , $w1 , $h1 , $w0 , $h0 ) ;<br /><br />imageDestroy($img) ;<br /><br />$imgSendFunc($tImg) ;<br />}<br />?&gt;<br />  
_________________________
DrChaos
LeetGamers

Top
#283042 - 01/11/05 11:49 PM Re: Question about this code... [Re: Duck]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
For a new window - changing this line:<br /><br /><a href="<?= "$dir/$filename" ?>"><br /><br />To this:<br /><br /><br /><a href="<?= "$dir/$filename" ?>" target="_blank"><br /><br /><br />Should do it. <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" />
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#283043 - 01/12/05 10:32 AM Re: Question about this code... [Re: Daine]
DrChaos Offline
Coder

Registered: 09/12/03
Posts: 816
Loc: Hollywood Florida.
bah, I was close. I was adding it like this <a href="<?= "$dir/$filename" ?>" target=_blank"><br /><br />Thanks again for the help Josh....
_________________________
DrChaos
LeetGamers

Top



Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks