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 }}
{{-- Using Antlers Blade Components --}}<statamic:assets container="photoshoots"> <img src="{{ $url }}" alt="{{ $alt }}" /></statamic:assets> {{-- Using Fluent Tags --}}@php $assets = Statamic::tag('assets')->container('photoshoots')->fetch();@endphp @foreach ($assets as $asset) <img src="{{ $asset->url }}" alt="{{ $asset->alt }}" />@endforeach
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
Every asset container has a unique handle. Pass it in and win! Default: assets
.
folder
Filter the resulting assets by specific folder. Default: none.
recursive
If you enable recursion, the tag will return all the assets in all the subdirectories that match your parameters. Default: false
.
limit
Limit the total results to a specific number.
offset
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
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.