我正在与一位摄影师客户合作创建一个简单的网站,我希望建立一个从 Dropbox 文件夹中提取的照片库,因此每当她想要更新图库中的图像时,她只需将照片从 Dropbox 文件夹中交换出来。很简单,对吧?
有没有办法使用 jQuery 或 PHP 从 Dropbox 目录中提取图像并将其显示到网页上?我已成功从 Dropbox 上的文本文件中提取文本,但我不知道目录中的图像是否可以实现同样的操作。
我做了一些 Google 搜索,但不断得到的结果教我如何将图片上传和下载到 Dropbox 目录 - 这不是我想要的。
这真的很简单。这是来自的一个片段http://davidwalsh.name/generate-photo-gallery http://davidwalsh.name/generate-photo-gallery点击此链接,您将找到解决问题的简单方法(包括演示)。
/** settings **/
$images_dir = '<path-to-your-dropbox>';
$thumbs_dir = '<path-to-your-generated thumbnails>';
$thumbs_width = 200;
$images_per_row = 3;
/** generate photo gallery **/
$image_files = get_files($images_dir);
if(count($image_files)) {
$index = 0;
foreach($image_files as $index=>$file) {
$index++;
$thumbnail_image = $thumbs_dir.$file;
if(!file_exists($thumbnail_image)) {
$extension = get_file_extension($thumbnail_image);
if($extension) {
make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width);
}
}
echo '<a href="',$images_dir.$file,'" class="photo-link smoothbox" rel="gallery"><img src="',$thumbnail_image,'" /></a>';
if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; }
}
echo '<div class="clear"></div>';
}
else {
echo '<p>There are no images in this gallery.</p>';
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)