油滑滑块不螺栓CMS显示图像
问题描述:
我所试图做的是从目录中加载的所有文件(图像)和每幅图像上追加了光滑的滑块。我初始化js文件中准备好的滑块,在初始化后我调用函数addImagestoSlider()。当我在本地测试站点时(这些图像被显示),这个工作正常,但是当我将它转换为螺栓cms时,图像不会显示在滑块中。我可以在检查元素中看到图像,但不显示。油滑滑块不螺栓CMS显示图像
JavaScript函数:
function addImagesToSlider() {
console.log("in addImagesToSlider");
var dirCars = "http://localhost/bolt/public/bolt/files/files/Cars";
const fileextension = ".jpg";
$.ajax({
//This will retrieve the contents of the folder if the folder is configured as 'browsable'
url: dirCars,
success: function success(data) {
//List all .jpg file names in the page
$(data).find("a:contains(" + fileextension + ")").each(function() {
let filename = this.href.replace(window.location.host, "").replace("http://", "");
console.log("filename: " + filename);
$('#cars_slider .slide-tracker').append(`
<figure>
<img src="${filename}"
</figure>
`);
});
}
});
}
答
这并不似乎是一个螺栓相关的问题。但是可以肯定的是,尝试检查服务器中的dirCars路由。
答
在仔细阅读Bolt文档后,我用完全不同的方式解决了这个问题。在.twig文件我装从目录中的图像到滑块直接这样说:
<div class="slider" id="cars_slider">
{% for image in record.gallery %}
<figure>
<img data-lazy="{{ thumbnail(image, 0, 0) }}">
</figure>
{% endfor %}
</div>