This is a script that list all image files on a given directory, and displays
the thumbnails nicely formated within an HTML table. It also make use of
JavScript to open pop up windows when the users want to see the full photo.
// THE PHP PHOTO GALLERY - DECEMBER 1999
// CODED BY
// ALEXANDRE MEYER LANA - JAU - BRASIL
// webmaster@lanavision.com or nagual@peyote.com
/* This is a script that list all image files on a given directory, and displays the thumbnails nicely
formated within an HTML table. It also make use of JavScript to open pop up windows when the
users want to see the full photo */
/* You can use one document per image subdirectory you want to display, or you may change the
code and access the gallery.php3 using a FORM, where you can parse the $path variable or any
other Anyway, it was a coffe break coding, I'll be glad to receive any improvements. */
/* I'll also be posting a CGI/PHP/mySQL eletronic postcard system pretty soon */
// Comments: webmaster@lanavision.com or nagual@peyote.com
// DON'T FORGET TO INCLUDE THE CLASS.FILE
// You can download it from:
// http://www.thewebmasters.net/php/File-1_0.tar.gz
include("class.File.php3");
// RELATIVE PATH TO IMAGES DIRECTORY (Other than gallery.php3's)
$path = "images";
// NUMBER OF COLUMNS TO BE DISPLAYED
$colunas = 6;
// THUMBNAIL WIDTH
$thumb_width = "100";
// THUMBNAIL HEIGHT
$thumb_height = "";
/* COORDINATES FOR THE FULL SIZE PHOTO POP-UP WINDOW
YOU CAN USE (MINUS) TO INVERT THE REFERENCES
(RIGHTMARGIN AND BOTTOMMARGIN). PREETY COOL, ISN'T IT? */
// LEFTMARGIN OFFSET (RIGTHMARGIN IF YOU USE NEGATIVE VALUES)
$pop_leftmargin = "1";
// TOPMARGIN OFFSET (BOTTOMMARGIN IF YOU USE NEGATIVE VALUES)
$pop_topmargin = "1";
<div align="center">
<BIG>PHP Photo Gallery</BIG><br>
<small>Coded by <b>Alexandre Meyer Lana</b> 1999<br>
<a href="mailto:webmaster@lanavision.com">webmaster@lanavision.com</a><br>
<br>
<b>(Click the thumbnails to enlarge Total in this page:
<?php echo count($images); ?> images)</b></small>
Matt Flagg wrote :267
If this was *really* cool, it would automatically create a 100x100 (or however specified) file using
GD and put it in a separate directory to be read from. Of course, doing on the fly would be piss
poor, so the sweetest thing would be to have something that detects the addition of a new file.
This would spawn a resizing function that creates the new x type file and puts it in the appropriate
directory. I don`t PHP would be the best thing for this, however. Anybody know how to "monitor"
a directory and perform things on freshly added files (with PHP or any other popular web technology)?
<p></p>
Having this kind of "hot" directory thing would be very cool.
pauldy wrote :282
You could have it check a directory and see if the
thumbnail file was there and if not create it from the
larger file on the fly. This means you take a
performance hit only once per image placed in the other
directory. Or just add a nifty upload feature and size it
as the file is uploaded.
Asbjorn Laurberg (webmaster at wiktor.dk) wrote :305
But the GD library in PHP don`t support .JPEG, so you
can`t make thumbernails based on JPEG files on the fly
with PHP. :-(
Joo Oliveira wrote :355
Parabns pelo seu trabalho. Estou estudando PHP e rodando
alguns excelentes exemplos encontrados em www.weberdev.com.
Eu indico este site para todos os meus amigos o tem um link
na minha HP
Vinnie Lima wrote :384
Great script!!!!! Now only if we can lace it up with mysql and add an upload page with the capability of
adding comments below each image - that would finish it up
Muito obrigado pelo script ;)
Vinicius Lima
Brasilia - now in Delaware
gabriel leung wrote :473
This script is self explained and work excellent.
Charles Lowe wrote :487
For those of you who are looking for a version with better thumbnailing (and since I can`t get GD to work... I wish they would just fix that), if you have Photoshop 5.5 - use the automate feature to create a web photo package. When you get the output files, upload the images and thumbnail folders to your server and change only one word line in the above code. In the bottom of the code where he is "echo"ing the table row change the img src tag to look like this:
In this line you will be replacing the variable/word "$path" to the word "thumbnails". You also want to make sure that the $path variable is set to "images".
You may want to set the $thumb_width = "" and $thumb_height = "" so you don`t end up resizing the thumbnails to a smaller or larger size then what Photshop created... although this could be a good thing if you make the thumbnails too big (but make the page load longer... better off re-running Photoshop to create smaller thumbnails). I hope this makes sense to you all and enjoy!!!
Great script by the way... very useful.
Chaz :-)
peter lindsey wrote :504
Haven`t tried the script yet, but it`s almot exactly what I was looking for. What a godsend.
For those of you who don`t have Photoshop, ACDSee can create thumbnails for you, It`s shareware. Also, Imagemagick is a command-line graphics conversion package which is free and available for most OSs. I use it in .bat files in W2K to create even sized (e.g. max width or height = 500pixel) Jpegs and thumbnails for whole directories of variously formatted graphics files for web display. http://www.simplesystems.org/ImageMagick/