Jonathan Dion
Jonathan Dion

Reputation: 1671

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?

Upvotes: 0

Views: 1054

Answers (1)

Luckyfella
Luckyfella

Reputation: 662

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 %}

Upvotes: 2

Related Questions