<p>To get all .mp4 files:</p>

<pre><code>{% set mp4s = craft.assets.filename('*.mp4').find() %}
</code></pre>

<p>To get the first .mp4:</p>

<pre><code>{% set mp4 = craft.assets.filename('*.mp4').first() %}
</code></pre>

CC BY-SA 3.0
2016-10-14T03:11:01.973Z
2016-10-14T03:11:01.973Z
Brad Bell
<p>Is it possible to query assets by it's filetype? </p>

<p>Example: I have a generic asset field, but I want to get the first asset that's an .mp4 file. </p>

<templating><assets>
Get asset by extension or mime type?
# Get asset by extension or mime type?

(Asked by: username_0 on 2016-10-13)

Is it possible to query assets by it's filetype?

Example: I have a generic asset field, but I want to get the first asset that's an .mp4 file.

**Tags:** templating, assets

---

## 1 answers

### Answer by username_1 on 2016-10-14. Score: 1 | Accepted answer

To get all .mp4 files:
{% set mp4s = craft.assets.filename('*.mp4').find() %}

To get the first .mp4:
{% set mp4 = craft.assets.filename('*.mp4').first() %}


---

