我有一个脚本可以扫描缩略图目录并将它们回显到页面。它工作得很好,但缩略图不可点击,我真的希望是这样。echo "<img src='$thumbnail' class='resizesmall'>";
是缩略图被回显的行。我不确定如何在不破坏它的情况下写入 php 中较大图像的路径。也许这应该在 foreach 语句中完成?感谢您的帮助?
$dir = "../mysite/thumbnails/";
$dh = opendir($dir);
// echo "$dh";
$gallery = array();
while($filename = readdir($dh))
{
$filepath = $dir.$filename;
//pregmatch used to be ereg
if (is_file($filepath) and preg_match("/\.png/",$filename))
{
$gallery[] = $filepath;
}
}
sort($gallery);
foreach($gallery as $thumbnail)
{
echo "<img src='$thumbnail' class='resizesmall'>";
}
?>
</div>
<??>