Assets Tag

Used to retrieve Assets directly from a container where you can then loop, filter, and sort them in expected but exciting ways.

Overview

If you ever find yourself needing to loop over all the assets in a container or folder instead of selecting them manually with the assets fieldtype, this tag was designed to make you smile.

{{ assets container="photoshoots" }}
    <img src="{{ url }}" alt="{{ alt }}" />
{{ /assets }}

This tag returns an array of Asset objects. You’ll have access to all the data and meta data on each file.

Parameters

id|container|handle string

Every asset container has a unique handle. Pass it in and win! Default: main.

folder string

Filter the resulting assets by specific folder. Default: none.

recursive boolean

If you enable recursion, the tag will return all the assets in all the subdirectories that match your parameters. Default: false.

limit integer

Limit the total results to a specific number.

offset integer

Skip a specific number of results. Useful for if you want to pull the first one out as a hero image or something similar.

sort string

Sort entries by any available asset variable, or random. Pipe-separate multiple fields for sub-sorting and specify sort direction of each field using a colon. Example: sort="size" or sort="size:asc|title:desc" to sort by size then by title.

Betterify this page on Github!