Previous Thread
Next Thread
Print Thread
Rate Thread
#283041 01/11/2005 10:02 PM
Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
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.



Code
<?<br />if( ! isset( $filename ) ){<br />define( "SIZE" , 120 ) ;<br />define( "COLNUM" , 5 ) ;<br />$dir = ($dir)?$dir:"." ;<br />?><br /><html><br /><head><br /><title>Our Pictures <?= $dir ?></title><br /><style type="text/css"><br /><!--<br />table{<br />width:100%;<br />}<br />td{<br />text-align:center;<br />}<br />img{<br />border:none;<br />}<br />--><br /></style><br /></head><br /><body><br /><table><br /><?<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 > 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&w0=$w0&h0=$h0&imgType=$imgType&h1=%d&w1=%d" , $h1 , $w1 ) ;<br /><br />if( ! ( $i % COLNUM ) ){<br />echo "\n<tr>\n" ;<br />}<br />?><br /><td><br /><a href="<?= "$dir/$filename" ?>"><br /><img src="<?= $filename ?>?<?= $params ?>" style="width:<?= $w1 ?>;height:<?= $h1 ?>;"></a><br><br /><?= "$filename : $w0 x $h0" ?><br /><?<br />$i++ ;<br />}<br />}<br />}<br />?><br /></table><br /></body><br /></html><br /><?<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 />?><br />  

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
For a new window - changing this line:

<a href="<?= "$dir/$filename" ?>">

To this:


<a href="<?= "$dir/$filename" ?>" target="_blank">


Should do it.

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
bah, I was close. I was adding it like this <a href="<?= "$dir/$filename" ?>" target=_blank">

Thanks again for the help Josh....


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)