keit che hai combinato al sito? è una bellezza!
ti posto la galleria fotografica, ho aggiunto le funz per PNG e GIF (prima faceva solo il formato JPEG)
O.K., qui trovi un utilizzo della galleria suddetta http://norbix.altervista.org/quad_supply/
allora, qui il PHP (index.php)
- Code: Select all
<div class = titlediv><span class = title>Photo Gallery</span></div>
<?php
$handle = opendir("images/");
/*while(($file = readdir($handle)) != false)
{
if((strstr($file, ".jpg") != false) || (strstr($file, ".JPG") != false))
{
@$result = fopen("thumbs/$file", "r");
if($result != NULL) fclose($result);
else thumb_maker($file);
echo "<a href = \"images/$file\"><image border = 0 src = \"thumbs/$file\"></a>";
}
}*/
echo "<table align = center border = 0 cellpadding = 2>";
echo "<tr>";
$i = 0;
while(($file = readdir($handle)) != false)
{
if((strstr($file, ".jpg") != false) || (strstr($file, ".JPG") != false) || (strstr($file, ".jpgeg") != false) || (strstr($file, ".JPGEG") != false) || (strstr($file, ".png") != false) || (strstr($file, ".PNG") != false) || (strstr($file, ".gif") != false) || (strstr($file, ".GIF") != false))
{
if($i == 4)
{
echo "</tr><tr>";
$i = 0;
}
@$result = fopen("thumbs/$file", "r");
if($result != NULL) fclose($result);
else thumb_maker($file);
$res = get_image_size("images/$file");
$size = filesize("images/$file") / 1024;
$size = round($size, 0); # arrotondamento 0 cifre dopo la virgola
#echo "<td><a href = \"images/$file\"><image border = 0 src = \"thumbs/$file\"></a></td>";
echo "<td><table border = 0 width = 240><tr><center><font size = 2>$file - $res - $size"."kB</font></center></tr><tr><a href = \"images/$file\"><image border = 0 src = \"thumbs/$file\"></a></tr></table></td>";
$i++;
}
}
closedir($handle);
if($i % 4 != 0) echo "</tr>"; # scrive </tr> (fine riga) a meno che non sia stato appena scritto
echo "</table>";
function get_image_size($image)
{
list($width, $height, $type, $attr) = getimagesize($image);
return $width."x".$height;
}
function thumb_maker($image)
{
list($width, $height, $type, $attr) = getimagesize("images/$image");
$thumb = imagecreatetruecolor(240, 180);
if((strstr($image, ".jpg") != false) || (strstr($image, ".JPG") != false) || (strstr($image, ".jpgeg") != false) || (strstr($image, ".JPGEG") != false))
{
$source = imagecreatefromjpeg("images/$image");
}
else if((strstr($image, ".png") != false) || (strstr($image, ".PNG") != false))
{
$source = imagecreatefrompng("images/$image");
}
else if((strstr($image, ".gif") != false) || (strstr($image, ".GIF") != false))
{
$source = imagecreatefromgif("images/$image");
}
imagecopyresized($thumb, $source, 0, 0, 0, 0, 240, 180, $width, $height);
if((strstr($image, ".jpg") != false) || (strstr($image, ".JPG") != false) || (strstr($image, ".jpgeg") != false) || (strstr($image, ".JPGEG") != false))
{
imagejpeg($thumb, "thumbs/$image", 75); # quality from 0 to 100
}
else if((strstr($image, ".png") != false) || (strstr($image, ".PNG") != false))
{
imagepng($thumb, "thumbs/$image", 7); # quality from 0 to 9
}
else if((strstr($image, ".gif") != false) || (strstr($image, ".GIF") != false))
{
imagegif($thumb, "thumbs/$image", 75); # quality from 0 to 100
}
}
?>
e qui il CSS (power_amp.css)
- Code: Select all
body
{
color: #ffffff;
background: #444444;
}
input
{
color: #ffffff;
background: #444444;
width: 100%;
text-align: center;
border-width: 1px;
border-color: #ffffff;
margin-left: 1px;
margin-right: 1px;
margin-top: 1px;
margin-bottom: 1px;
}
textarea
{
color: #ffffff;
background: #444444;
/*text-align: center;*/
border-width: 1px;
border-color: #ffffff;
margin-top: 1px;
margin-bottom: 1px;
}
a
{
text-decoration: none;
}
a:link
{
color: #00ff00;
}
a:visited
{
color: #00ff00;
}
a:hover
{
color: #ffffff;
}
a:active
{
color: #00ff00;
}
div
{
width: 85%;
text-align: center;
margin-left: auto;
margin-right: auto;
}
.titlediv
{
margin-top: 25px;
margin-bottom: 25px;
}
.title
{
font-size: 35px;
margin-left: auto;
margin-right: auto;
color: #ffffff;
}
.nickdiv
{
text-align: left;
}
.fullwidth
{
width: 100%
}
.textdiv
{
# width: 100%;
text-align: left;
}
.nickname
{
color: #00ff00;
# font-weight: bold;
}
ricordo che ci vogliono le cartelle images e thumbs, nella prima bisogna inserire le immagini, nella seconda saranno salvati i thumbs (anteprime)

