twigadvanced-custom-fieldstimber

Output Image from ACF options field


How can I output an image from the ACF options field with Timber/Twig?

Below is what I have now, but unfortunately it isn't working. I just can't get it done. What am I doing wrong?

Timber controller

$context['theme_options'] = get_fields('options');

Twig file

<img src="{{ Image(options.footer_logo).src }}" />

Solution

  • As @DarkBee mentioned in a comment to your question, you’re using options instead of theme_options in your Twig file. Try using this:

    Twig file

    <img src="{{ Image(theme_options.footer_logo).src }}" />
    

    The rest seems to be looking good.

    In case you want to check what’s inside theme_options in Twig, you can use the dump() function:

    {{ dump(theme_options) }}