Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-14T03:11:01.973Z
Answers.LastActivityDate: 2016-10-14T03:11:01.973Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <templating><assets>
Title: Get asset by extension or mime type?
ThreadText: # 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() %}
  
  ```
  
  
  ---
  
  