我正在使用Lightgallery,一切正常,除非我<h1>
在 foreach 循环中回显标签。当我删除它时,画廊工作正常。
添加标签时唯一的问题<h1>
是图像没有被加载。我只是看到预加载器永远加载。这可能是什么原因造成的?
我的代码:
<div id="lightgallery" style="border-top: 2px solid rgb(230, 230, 230);">
<?
$dir = $_SERVER['DOCUMENT_ROOT'].'/images/PROJECTEN/';
$folders = array_diff(scandir($dir), array('index.html', '.', '..'));
function scan_dir($dir) {
$ignored = array('.', '..', '.svn', '.htaccess','index.html');
$files = array();
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
arsort($files);
$files = array_keys($files);
return ($files) ? $files : false;
}
foreach($folders as $gallerypart){
$nounderscore = str_replace('_', ' ', $gallerypart);
$gallery .= '<h1>'.$nounderscore.'</h1>';
foreach(scan_dir($_SERVER['DOCUMENT_ROOT'].'/images/PROJECTEN/'.$gallerypart.'/') as $entry) {
$gallery .= '
<a href="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'">
<img class="galleryimg" src="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'" />
</a>';
}
}
echo $gallery;
?>
</div>
这是破坏它的部分:
$gallery .= '<h1>'.$nounderscore.'</h1>';