添加 h1 标签时 Lightgallery 不工作?
Lightgallery not working when adding h1 tag?
我正在使用 Lightgallery 并且一切正常,除非我在 foreach 循环中回显 <h1>
标记。当我删除它时,画廊工作正常。
当我添加 <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>';
我通过使用选择器而不是标准标记来修复它。
像这样:
<script type="text/javascript">
$(document).ready(function() {
$('#selector1').lightGallery({
selector: '.item'
});
});
</script>
然后在循环中添加以下代码:
$gallery .= '
<div class="item" data-src="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'">
<img class="galleryimg" src="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'" />
</div>';
我正在使用 Lightgallery 并且一切正常,除非我在 foreach 循环中回显 <h1>
标记。当我删除它时,画廊工作正常。
当我添加 <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>';
我通过使用选择器而不是标准标记来修复它。
像这样:
<script type="text/javascript">
$(document).ready(function() {
$('#selector1').lightGallery({
selector: '.item'
});
});
</script>
然后在循环中添加以下代码:
$gallery .= '
<div class="item" data-src="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'">
<img class="galleryimg" src="http://www.website.nl/images/PROJECTEN/'.$gallerypart.'/'.$entry.'" />
</div>';