|
|
|
<?php
// 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
// P.S.: Sorry for my english, it's not so good
//***********************************************************//
//******** STARTOF VARIABLES CONFIGURATION SECTION **********//
//***********************************************************//
// 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";
//***********************************************************//
//******** ENDOF VARIABLES CONFIGURATION SECTION ************//
//***********************************************************//
$file = new File();
$images = array();
$jpgs = $file->get_files("$path","jpg");
if( !empty($jpgs) ) {
while ( list( $key, $filename ) = each( $jpgs ) ) {
$images[] = $filename;
}
}
$gifs = $file->get_files("$path","gif");
if( !empty($gifs) ) {
while ( list( $key, $filename ) = each( $gifs ) ) {
$images[] = $filename;
}
}
$pngs = $file->get_files("$path","png");
if( !empty($pngs) ) {
while ( list( $key, $filename ) = each( $pngs ) ) {
$images[] = $filename;
}
}
$bmps = $file->get_files("$path","bmp");
if( !empty($bmps) ) {
while ( list( $key, $filename ) = each( $bmps ) ) {
$images[] = $filename;
}
}
$count = 1;
$break = $colunas;
?>
<!-- STARTOF HTML CODE - CUSTOMIZE AS YOU WISH -->
<!-- JUST DON'T TOUCH THE JAVA CODE -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>The PHP Photo Gallery</TITLE>
<SCRIPT Language="JavaScript">
<!--
var popWin = null
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 20
var d_winTop = 20
winName = "popWin" + winCount++
closePopWin()
if (openPopWin.arguments.length >= 4)
winFeatures = "," + winFeatures
else
winFeatures = ""
if (openPopWin.arguments.length == 6)
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth
+ ",height=" + winHeight + winFeatures)
}
function closePopWin(){
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4)
if(popWin != null) if(!popWin.closed) popWin.close()
}
function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation = ",screenX=" + winLeft + ",left=" + winLeft
+ ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
//-->
</SCRIPT>
<style>
<!--
BODY {
font-family: Verdana,Arial;
font-style: none;
font-size: 16px;
}
BIG {
font-size: 28px;
font-weight: bold;
}
TABLE {
font-size: 16px;
}
SMALL {
font-size: 12px;
}
A:LINK {
text-decoration: none;
font-weight: bold;
}
-->
</style>
</HEAD>
<BODY onUnload="closePopWin()">
<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>
<table border="5" cellspacing="0" cellpadding="6">
<tr>
<!-- STARTOF TABLE CELL DISPLAY PHP CODE -->
<!-- DO NOT ALTER IT -->
<?php
while ( list( $key, $fileName ) = each( $images ) )
{
if( !empty($fileName) )
{
$tamanho = GetImageSize("$path/$fileName");
$largura = $tamanho[0] + 18;
$altura = $tamanho[1] + 28;
echo " <td align=\"CENTER\" valign=\"TOP\"><a href='javascript:openPopWin(\"$path/
$fileName\", $largura, $altura, \"\", $pop_leftmargin, $pop_topmargin)'><IMG SRC=\"$path/
$fileName\" border=0 alt=\"$count\"";
if (!empty($thumb_width)) {echo " width=\"$thumb_width\"";}
if (!empty($thumb_height)) {echo " height=\"$thumb_height\"";}
echo "></a><br><small>$count</small>";
if ($count == $break) {
echo "\n </td>\n</tr>\n<tr>\n";
$break = $count + $colunas;
}
else { echo "</td>\n"; }
}
$count++;
}
?>
<!-- ENDOF TABLE CELL CODE PHP-->
</tr>
</table>
</div>
<hr>
<div align="CENTER">
<b>The PHP Photo Gallery</b><br>
<small>Coded by <b>Alexandre Meyer Lana</b> ® 1999<br>
<a href="mailto:webmaster@lanavision.com">webmaster@lanavision.com</a></small>
</div>
</BODY>
</HTML>
|
|
| Complete NotePad application for Websites (Like Yahoo Notepad) Categories : PHP, Web Applications, Filesystem, Java Script, Complete Programs | | | Validator 98 - a PHP-script to generate form-validation-code in JavaScript. Categories : Complete Programs, Java Script, PHP, HTML and PHP | | | Builds JavaScript that updates the contents of one selector based on another. Categories : HTML, Java Script, PHP, Complete Programs, General | | | This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs | | | Automatic banner rotation. Randomly selects a banner for display. Categories : Graphics, PHP, Complete Programs | | | Using PHP im HTML image tags Categories : PHP, HTML and PHP, Graphics, Beginner Guides | | | This script allows people to add their favorite quotes to your website. This
could easily be modified to be a guestbook script or comment page script. Categories : PHP, Complete Programs, HTML and PHP, Misc | | | AJAX Data Grid System using php and mysql. A complete login system with the ability to display data in a grid using ajax. Add , update and delete the records without reloading the page. Categories : PHP, AJAX, Databases, MySQL, Java Script | | | PHP mySQL learning example This is a complete program to modify tables
in a mySQL database on a nice and neat way. Categories : PHP, MySQL, Complete Programs, HTML and PHP | | | phpFreeChat Categories : PHP, AJAX, Complete Programs | | | A database abstraction layer for the PHP 3.0 ODBC module. It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface. Categories : Databases, PHP, Complete Programs | | | The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP, PHP Classes, Java Script, AJAX, Databases | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | Contents Page - a script to build contents pages. Categories : Complete Programs, PHP, Utilities, Filesystem | | | Simple PHP/3 Access Counter (using GD and DBM functions) Categories : Databases, PHP, Graphics, HTML and PHP, dBase | |
| | | | 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. :-(
| | | | João Oliveira wrote : 355
Parabéns 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:
<IMG SRC=\"thumbnails/$fileName\" border=0 alt=\"$count\"
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/
| |
|
|