Skip to main content

page.attachments Count

I want to automatically display a gallery for page.attachments, but only if the page has multiple image attachment. Is there a _count variable for page.attachments or another way to get the array count? Seems like a simple task, but the API isn't showing anything.

Something like this:

    {% if page.attachments_count > 1 %}  
        {% include "gallery" %}
    {% endif %}  

That obviously doesn't work since _count isn't a variable. Though it should be!

Official response from

You should be able to use "page.attachments.size".

Share this post

Showing 4 reactions

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