|
|
|
|
|
|
| |
| <?
// Title : Complete Image Gallery.
// Version: 1.0.1
// Author: Mian Shafiq-ur-Rehman
// Email : gurru@phpgurru.com
// Mess : rehmanms@hotmail.com
// Website: www.phpgurru.com
// 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. */
if(is_dir($dir))
{
$allFiles = opendir($dir);
//echo count($allFiles);
while ($file = readdir($allFiles))
{
if(!is_dir($dir.'/'.$file))
{
if (preg_match($re,strtolower($file)))
{
$thumbs[] = popup_window($dir.'/'.$file);
}
}
}
closedir($allFiles);
}
$totalThumbs = count($thumbs);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Image Gallery</title>
<style type="text/css">
<!--
.style2 {
color: #006699;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style3 {
color: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
-->
</style>
</head>
<body>
<h1><span class="style2">Image Gallery</span>
<hr>
</h1>
<table border="0" bordercolor="#CCCCCC">
<?
$j=0;
for ($i=0; $i<$totalThumbs; $i++)
{
if($i == $j)
{
$j+=$inOneRow;
echo "<tr>";
}
?>
<td width="115" align="left"><table width="110" height="142" border="1" cellpadding="5" cellspacing="0" bordercolor="#006699">
<tr align="center">
<td height="120" valign="middle"><? echo $thumbs[$i]?></td>
</tr>
<tr align="center">
<td valign="middle" bgcolor="#006699"><span class="style3"><? echo "Caption " . $i?></span></td>
</tr>
</table></td>
<?
}
?>
</tr>
</table>
</body>
</html> | | |
|
| Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page. Categories : PHP, AJAX, HTML and PHP, Java Script | | | Dynamic generation of textboxes, select items etc in a table for use with databases applications, matrimonials and for job sites Categories : PHP, HTML and PHP, Java Script | | | Tree Menu Dynamic (+Static) with Loading in Progress.. Categories : PHP, Java Script, HTML and PHP | | | OverEasy - PHP generated JavaScript to do mouseovers on
your pages. Modify one file and one function does it all
for you! Categories : PHP, Java Script, HTML and PHP, MySQL | | | This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field Categories : PHP, MySQL, Java Script, HTML and PHP | | | Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP | | | Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP, Date Time, HTML and PHP, Java Script | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Newbie Notes #9 - Hyperlinking a post Categories : PHP, Java Script, HTML and PHP, Beginner Guides | | | PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions | | | Dynamic Calender in PHP, Javascript and HTML. Categories : PHP, Java Script, HTML and PHP, Calendar | | | Validator 98 - a PHP-script to generate form-validation-code in JavaScript. Categories : Complete Programs, Java Script, PHP, HTML and PHP | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | |
| | | | 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.
Any tips?
Joshua
| |
|
|
|