2017-09-27 223 views
-1

我所試圖做的是從目錄中加載的所有文件(圖像)和每幅圖像上追加了光滑的滑塊。我初始化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> 
      `); 
     }); 
    } 
}); 
} 

回答

0

這並不似乎是一個螺栓相關的問題。但是可以肯定的是,嘗試檢查服務器中的dirCars路由。

0

在仔細閱讀Bolt文檔後,我用完全不同的方式解決了這個問題。在.twig文件我裝從目錄中的圖像到滑塊直接這樣說:

<div class="slider" id="cars_slider"> 
     {% for image in record.gallery %} 
     <figure> 
      <img data-lazy="{{ thumbnail(image, 0, 0) }}"> 
     </figure> 
     {% endfor %} 
    </div>