Image Attachments: Set Default File, Use If and Else for Various States

I have a few pages, some have images others don't. I'd like to set a default image for pages that don't have image attachments added in 'Files'. If an attachment has a specific file name that should be featured if not swap to a default image.

This clumsy markup below seems to do the job partially, only if there's 1 or 0 file attachments. However if there is more than 1 file attachment in a page it does not work.

Any insight or help will be appreciated. Thanks

Official response from

Unfortunately it looks like the markup has been lost when you submitted the page. However, if your method is only working for one attachment, then it is likely that you will need to wrap it in a for loop for all attachments to make it work when there are multiple present, like this:

{% for attachment in page.attachments %}
Your code here
{% endfor %}

Complete and current information on how to use NationBuilder is available in the documentation section.

Do you like this post?

Showing 1 reaction

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.