note 42520 deleted from function.getimagesize by betz
| From: | betz@php.net | Date: | Wed, 20 Oct 2004 14:05:23 +0000 |
| Subject: | note 42520 deleted from function.getimagesize by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78830@lists.php.net to get a copy of this message | ||
Note Submitter: diablx at hotmail dot com
----
Hi, this is my first post to php.net... I give you a little thumbnail images resize. It list the
directory content images :
<?
// Some configuration variables !
$maxWidth = 100;
$maxHeight = 100;
$maxCols = 8;
$webDir = "https://www.davannsolutions.com/images/";
$localDir = $_SERVER['DOCUMENT_ROOT']."/images/";
$AutorisedImageType = array ("jpg", "jpeg", "gif", "png");
?>
<center>
<table border='1' cellspacing='10' cellpadding='0'
style="border-collapse:collapse; border-style: dotted">
<tr>
<?
// Open localDir
$dh = opendir($localDir);
while (false !== ($filename = readdir($dh))) {
$filesArray[] = $filename;
}
// Display and resize
foreach ($filesArray as $images) {
$ext = substr($images, strpos($images, ".")+1, strlen($images));
if( in_array($ext, $AutorisedImageType) ) {
list($width, $height, $type, $attr) = @getimagesize( $localDir.$images );
if($width <= $maxWidth && $height <= $maxHeight) {
if($i == $maxCols) {
echo "</tr><tr>";
$i = 0;
}
echo "<td align='center' valign='middle' width='$maxWidth'
height='$maxHeight'><img
src='".$webDir.$images."'></td>";
$i++;
}
else {
if($width > $maxWidth && $height <= $maxHeight) {
if($i == $maxCols) {
echo "</tr><tr>";
$i = 0;
}
echo "<td align='center' valign='middle'
width='$maxWidth' height='$maxHeight'><img
src='".$webDir.$images."' width='$maxWidth'></td>";
$i++;
}
if($width <= $maxWidth && $height > $maxHeight) {
if($i == $maxCols) {
echo "</tr><tr>";
$i = 0;
}
echo "<td align='center' valign='middle'
width='$maxWidth' height='$maxHeight'><img
src='".$webDir.$images."' height='$maxHeight'></td>";
$i++;
}
}
}
}
?>
</tr>
</table>
</center>