// This program displays thumbnails from any directory and creates popup windows after calculating the
// Height and Width of image with java script. Setting up image gallery on your site is the game of few
// seconds. I will add resizing of thumbs in next release.
// Please download the attached ZIP file for code and images.
// For working demo please visit http://demos.phpgurru.com/gallery/
$dir = "images/"; // Directory in which your images are placed.
$re = "/\.(jpg|gif|psd)$/"; // filter for selection of images
$inOneRow = 5; // how many images you want to display in one row.
?>
<script language="javascript">
function loadWindow(imgPath,width,height) {
var msgWindow = window.open("","Window_" + Math.floor(Math.random() * 10000000), "width=" + width +",height=" + height +"");
msgWindow.document.write("<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=windows-1256'>\n<title>Picture preview</title>\n</head>\n<body>\n");
msgWindow.document.write("<table width='100%' height='100%' border='1' cellpadding='10' cellspacing='5' bordercolor='#0066FF'>\n<tr>\n<td align='center' valign='middle'>\n");
msgWindow.document.write("<img src='" + imgPath +"'>");
msgWindow.document.write("</td></tr></table></body>\n</html>\n");
msgWindow.focus();
return true;
}
</script>
<?
function popup_window($imgPath)
{
if(file_exists($imgPath))
{
$size= @getimagesize( $imgPath );
$width=$size[0];
$height=$size[1];
$width = ($width < 200 ? 250 : ($width + 50));
$height = ($height < 300 ? 350 : ($height + 50));
$popup= "<a href='#' onClick=\"javascript:loadWindow('". $imgPath ."', " . $width . ", " . $height .");\"><img src='$imgPath' height=120 width=90 alt='View Image' border=0></a>";
return $popup;
}
}
/* Pass complete path of image to my routine and it will display a Link ~View Image~. On clicking this will open a new popup window according to the size of image. Kepp in mind that your popup blocker is turned off. */
Lennart Ericson wrote :1293
Hi, Very good script! Thanks for making it public.
Joshua Yip wrote :1294
I cant seems to get this working. save the file, upload it to a directory with images, jpg and gif, but nothing is displayed. Enabled pop up. Nothing is showing.