Max 5 Thumbnails in einer Reihe?
Verfasst: 14.03.2005 12:16
Hallo, ich benutze folgendes Script, um alle Bilder aus einem Verzeichnis darstellen zu können:
Nun wird der komplette browser genutzt um die thumbnails darzustellen. Ich möchte aber, dass max 5 oder 6 thumbnails in eine Reihe kommen. Da ich in PHP nicht so bewandert bin, frage ich nun hier, wo und wie ich den code ändern kann.
Vielen Dank schon mal
Code: Alles auswählen
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<?php
include("http://www.meinserver.de/albumarchiv.php");
error_reporting(0);
$handle = opendir("./tnails");
while (true == ($file = readdir($handle)))
{
if (file_exists("./bilder/".$file) == false)
unlink("./tnails/".$file);
}
$handle = opendir("./bilder");
$inhalt = array();
$i = 0;
while (true == ($file = readdir($handle)))
{
if (getimagesize("./bilder/".$file) == true)
{
$i++;
$inhalt[$i] = $file;
if (file_exists("./tnails/".$file) == false)
{
if (imagecreatefromgif("./bilder/".$file) == true)
$im_bild = imagecreatefromgif("./bilder/".$file);
if (imagecreatefromjpeg("./bilder/".$file) == true)
$im_bild = imagecreatefromjpeg("./bilder/".$file);
if (imagecreatefrompng("./bilder/".$file) == true)
$im_bild = imagecreatefrompng("./bilder/".$file);
$picinfo = getimagesize("./bilder/".$file);
$width_orig = $picinfo[0];
$height_orig = $picinfo[1];
$width = 124;
$height = 93;
if (($width_orig / $height_orig) <= ($width / $height))
{
$width = ($height / $height_orig) * $width_orig;
}
else
{
$height = ($width / $width_orig) * $height_orig;
}
$im_tnail = imageCreateTrueColor($width, $height);
imageCopyResampled($im_tnail, $im_bild, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
$im_fertig = imageCreateTrueColor(124, 107);
$color = ImageColorAllocate($im_fertig, 1, 86, 126);
imagefill($im_fertig, 0,0, $color);
$dst_x = (124 - $width) / 2;
$dst_y = (93 - $height) / 2;
ImageCopy($im_fertig, $im_tnail, $dst_x, $dst_y, 0, 0, $width, $height);
$color = ImageColorAllocate($im_fertig, 1, 86, 126);
imagerectangle($im_fertig, 0, 0, 123, 92, $color);
$color = ImageColorAllocate($im_fertig, 1, 86, 126);
imagestring($im_fertig, 1, 0, 95, $file, $color);
imagejpeg($im_fertig, "./tnails/".$file);
}
}
}
$nl = chr(13) . chr(10);
$fp = fopen("liste.txt","w");
echo "<center>";
for($zaehler = 1; $zaehler <= $i; $zaehler++)
{
echo "<a href=\"detail.php?bild_id=".$zaehler."\"><img src=\"tnails/".$inhalt[$zaehler]."\" border=\"0\"></a> ";
fputs ($fp, "|".$zaehler."| ".$inhalt[$zaehler].$nl);
}
fclose($fp);
// echo "<br><br><form method=\"post\" action=\"upload.php\" enctype=\"multipart/form-data\">";
// echo "<input type=\"file\" name=\"local\" size=\"25\" style=\"height: 22px;\"> ";
// echo "<input type=\"submit\" name=\"subscribe\" value=\"Bild hochladen\" style=\"height: 22px;\">";
echo "</form>";
echo "</center>";
?>
</body>
</html>
Vielen Dank schon mal