# Assets

Used to retrieve [Assets](/assets.md) 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](/fieldtypes/assets.md), this tag was designed to make you smile.

::tabs

::tab antlers
```antlers
{{ assets container="photoshoots" }}
    <img src="{{ url }}" alt="{{ alt }}" />
{{ /assets }}
```

::tab blade
```blade
{{-- 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](/assets.md) objects. You'll have access to all the data and meta data on each file.

## Filtering

### Conditions

You can filter assets using the same [conditions syntax][conditions] available on the Collection tag. This works against both built-in asset properties (`filename`, `extension`, `size`, etc.) and any custom fields defined on the container's blueprint.

::tabs
::tab antlers
```antlers
{{ assets container="photos" extension:is="jpg" alt:contains="sunset" }}
    <img src="{{ url }}" alt="{{ alt }}" />
{{ /assets }}
```

::tab blade
```blade
<statamic:assets
    container="photos"
    extension:is="jpg"
    alt:contains="sunset"
>
    <img src="{{ $url }}" alt="{{ $alt }}" />
</statamic:assets>
```
::

Common conditions include `:is`, `:isnt`, `:contains`, `:starts_with`, and `:ends_with`. See the full list on the [conditions page][conditions].

### Filter by Type

Limit results to a single media type using the `type` parameter. Valid values are `audio`, `image`, `svg`, and `video`.

```antlers
{{ assets container="uploads" type="image" }}
    <img src="{{ url }}" alt="{{ alt }}" />
{{ /assets }}
```

### Custom Query Scopes

For more complex filtering, create a [query scope](/extending/query-scopes-and-filters.md) and reference it with `query_scope`:

```antlers
{{ assets container="photos" query_scope="recent_hero_shots" }}
    <img src="{{ url }}" alt="{{ alt }}" />
{{ /assets }}
```

[conditions]: /conditions
