Answers.Body: <p>See <code>kind</code> in the docs: <a href="https://craftcms.com/docs/templating/assetfilemodel" rel="nofollow noreferrer">https://craftcms.com/docs/templating/assetfilemodel</a></p>
  
  <p>I haven't tried it but I suspect it's something like this:</p>
  
  <pre><code>{% set file = assetsField.first %}
  {% if file.kind == 'image' %}
    // blah blah
  {% endif %}
  </code></pre>
  
  <p>There's also <code>extension</code> but kind is probably better here.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-18T12:26:38.497Z
Answers.LastActivityDate: 2017-02-18T12:26:38.497Z
Answers.UserDisplayName: Clive Portman
Answers.Body: <p>In addition to the model’s <code>kind</code> property mentioned in the other answer, there is also a <code>kind</code> parameter for asset criteria models.</p>
  
  <pre><code>{% set containsVid = assetsField.kind('video').total() &gt; 0 %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-18T13:03:25.370Z
Answers.LastActivityDate: 2017-02-18T13:03:25.370Z
Answers.UserDisplayName: carlcs
Body: <p>What’s the best way to check if an assets field contains a file of a certain type?</p>
  
  <p>Something to the effect of: <code>if assetsField.contains.file-of-type('image')</code></p>
  
Tags: <templating><assets>
Title: Check if Assets Field Contains File of Type
ThreadText: # Check if Assets Field Contains File of Type
  
  (Asked by: username_0 on 2017-02-18)
  
  What’s the best way to check if an assets field contains a file of a certain type?
  
  Something to the effect of: `if assetsField.contains.file-of-type('image')`
  
  **Tags:** templating, assets
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-02-18. Score: 2
  
  See `kind` in the docs: <https://craftcms.com/docs/templating/assetfilemodel>
  
  I haven't tried it but I suspect it's something like this:
  
  ```
  {% set file = assetsField.first %}
  {% if file.kind == 'image' %}
    // blah blah
  {% endif %}
  
  ```
  
  There's also `extension` but kind is probably better here.
  
  
  ---
  
  ### Answer by username_2 on 2017-02-18. Score: 1
  
  In addition to the model’s `kind` property mentioned in the other answer, there is also a `kind` parameter for asset criteria models.
  
  ```
  {% set containsVid = assetsField.kind('video').total() > 0 %}
  
  ```
  
  
  ---
  
  