【发布时间】:2017-04-06 16:36:36
【问题描述】:
我制作了一个简单的图片库,我正在添加受密码保护的上传。在一些帮助下,我正在使用this php(感谢sulthan-allaudeen)。附上我正在使用的代码。
问题是我找不到在左侧显示文件夹中所有图像的缩略图的方法,但是使用此代码,我只有全角图像。有什么想法吗?
谢谢
<body>
<div id="containerfoto">
<div id="gallery">
<div id="minipics">
<?php
$dir = 'Images/photo/';
$files = scandir($dir);
$i = 1;
foreach ($files as $key)
{
if ($i>3)
{
$j = $i-3;
echo "<a href='Images/photo/".$key."'><img src ='Images/photo/".$key."'>".$key."</a>";
}
$i++;
}
?>
<div style="clear:left"> </div>
</div>
<div id="zoom">
<img src="Images/foto/foto7.jpg" id="bigimage" alt="">
<h3 id="titolo">Click to enlarge images.</h3>
</div>
</div>
</div>
<script>
window.onload=function(){
if(!document.getElementById || !document.getElementsByTagName) return;
links=document.getElementById("minipics").getElementsByTagName("a");
for(i=0;i<links.length;i++)
links[i].onclick=function(){Show(this);return(false)}
}
function Show(obj){
bigimg=document.getElementById("bigimage");
bigimg.src=obj.getAttribute("href");
smallimg=obj.getElementsByTagName("img")[0];
t=document.getElementById("titolo");
t.removeChild(t.lastChild);
t.appendChild(document.createTextNode(smallimg.title));
}
</script>
</body>
【问题讨论】:
-
问题依然存在,问题现在是什么状态:)
-
嗨,苏丹阿劳丁!杰伊真的在帮我处理这段代码,实际上这是代码pastebin.com/XsPKZheE,它正在工作但有一些问题:3 个开始的缩略图不是图像,但我认为文件夹目录或类似的东西,以及带有图像的缩略图之后(嗯有序且工作正常)有很多其他缩略图的无效链接(其中包含丢失图片的图像,因为文件夹中没有其他图片)这是示例图像:dropbox.com/s/oxgh2vaogrr49dl/example.png?dl=0
-
我已将你添加到我和 Jay 之间的聊天中
-
听到这个消息真是太好了!
标签: javascript php html image gallery