Plocka den kod du behöver ifrån/innifrån detta fungerande exempel:
<?php
//Gallery Title
$headertitle = 'This is My Gallery V2';
//how many cols of images do we want before a new line
$cols=4;
//Max width of image so it does not break our page
$width = 700;
?>
<HTML>
<HEAD>
<TITLE><?php echo $headertitle;?></TITLE>
<!-- include our css file -->
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen">
<!-- include the JS file for the image popups -->
<script type="text/javascript" src="lightbox.js"></script>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
<table width="700" height="50" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><?php echo $headertitle;?></div></td>
</tr>
</table>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<?php
//initiate our counter to 1
$i=1;
echo '<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">';
/*glob does the same as readdir, but is more safe as it cannot be injected as it reads from our CURRENT folder only and no deeper. You can change the file extensions you want here * is a wild card so to add PNG we would need to add *.png,*.PNG so we read both cases*/
foreach (glob("{*.jpg,*.JPG,*.gif,*.GIF}",GLOB_BRACE) as $file)
{
if(file_exists("thumbs/".$file)) //make sure a thumbnail exists
{
if($i == 1) //check to see if our counter is reset and create the cell start
{
echo "<tr>";
}
$size = getimagesize($file); //lets find our image sizes to check max width where $size[0] => Width $size[1] => Height
$w1 = $size[0];
$h1 = $size[1];
// lets get the file size in byte/kb/mb.
$file_size = filesize($file);
if ($file_size >= 1048576){
$show_filesize = number_format(($file_size / 1048576),2) . " MB";
}elseif ($file_size >= 1024){
$show_filesize = number_format(($file_size / 1024),2) . " KB";
}elseif ($file_size >= 0){
$show_filesize = $file_size . " bytes";
}else{
$show_filesize = "0 bytes";
}
//Gets file modification time
$last_modified = date ("F d Y H:i:s", filemtime($file));
/*here we have added a rel="lightbox" title="'.$file.'" for use with the new image popup and changed the url to just the image as the action=view is no longer used*/
echo '<td align="center">'.$file.'<br><a href="'.$file.'" title="'.$file.'" rel="lightbox"><img src="thumbs/'.$file.'" border="0" width="100" hspace="5" vspace="5"></a><br>Size '.$w1.' / '.$h1.'<br>File Size '.$show_filesize.'<br>Last Modified '.$last_modified.'</td>';
if($i == $cols) //check to see if our counter matches our column count
{
echo "</tr>";
$i=0; //reset our counter to 0 so we know it is a new row
}
$i++; // lets increment our counter
}
}
echo '</table>';
?>
</td>
</tr>
</table>
</BODY>
</HTML>