Reputation: 376
I am experiencing the following error when trying to display an image gallery Advanced Custom Field's field on my client's website.
Fatal error: Uncaught Exception: Unknown "get_image" function.
I have tried switching the image galleries return format between array, URL, and ID, but the same issue always occurs.
The code that I am using to display the gallery of images is being used in a category Twig file using the following code. Not all story posts have galleries, but the if statement should be handling this I assume.
I copied the gallery output code directly from the Timber documentation site.
Timber is up to date using 1.18.2.
{% if story.meta( 'photo_gallery' ) %}
{% for image in story.meta( 'photo_gallery' ) %}
<img src="{{ get_image(image) }}" />
{% endfor %}
{% endif %}
Upvotes: 2
Views: 994
Reputation: 2794
That’s actually an error in the documentation. The get_image()
function is a function from the upcoming 2 version of Timber, but shouldn’t be listed in the documentation for version 1.
It should work if you use Image()
instead of get_image()
:
{% if story.meta( 'photo_gallery' ) %}
{% for image in story.meta( 'photo_gallery' ) %}
<img src="{{ Image(image) }}" />
{% endfor %}
{% endif %}
I’ll check if I can get the documentation fixed.
Update – This is now fixed in the documentation.
Upvotes: 1
Reputation: 1751
If you are using ACF plugin, you can use below code to get the ACF image:
{% for item in block_content.add_services %}
<img src="{{ item.add_service_logo.url }}" alt="{{ item.add_service_logo.alt}}" >
{% endfor %}
add_services is for the ACF repeater and add_service_logo is used for the image (return as an array).
Upvotes: 0
Reputation: 4534
The Advanced Custom Fields plugin does not implement a get_image
function. Are you sure it shouldn't be get_field(image)
instead of get_image(image)
?
Upvotes: 0