简体   繁体   中英

Can't get image with ACF and Timber

It's my first time with Timber/Wordpress.

I'm trying to use this plugin with Timber but I can't render any image.

I'm only getting the ids of the images:

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

I also try:

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

I looked at the documentation

How can I get all the src of my images?

It depends on how or if your field gallery_images is nested further (via ACF). If it's not nested it should work like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM