2017-05-13 16 views
0

這是我第一次使用木材/ Wordpress。無法使用ACF和木材獲取圖像

我想用木材this plugin但我無法渲染任何圖像。

我只得到了圖像的ID:

{% set images = post.get_field('gallery_images') %} // "47,48" 

我也嘗試:

if (isset($post->hero_image) && strlen($post->hero_image)){ 
    $post->hero_image = new TimberImage($post->hero_image); 
} 

我看着documentation

我怎麼能得到的所有的SRC我的圖片?

回答

1

這取決於如何或如果您的字段gallery_images進一步嵌套(通過ACF)。 如果它沒有嵌套它應該像這樣工作:

{% for image in post.get_field('gallery_images') %} 
    <img src="{{ TimberImage(image).src }}" alt="" /> 
{% endfor %}