<p>You can achieve this using the <a href="https://docs.craftcms.com/api/v3/craft-config-generalconfig.html#extrafilekinds" rel="noreferrer"><code>extraFileKinds</code> config setting</a> like this:</p>
<pre><code>'extraFileKinds' =&gt; [
    'svg' =&gt; [
        'label' =&gt; 'SVG',
        'extensions' =&gt; ['svg'],
    ],
],
</code></pre>
<p>On your Asset field, check the &quot;Restrict allowed file types?&quot; checkbox, and select &quot;SVG&quot; from the list.</p>

CC BY-SA 4.0
2020-08-27T18:50:27.020Z
2020-08-27T18:50:27.020Z
André Elvan
<p>I want to have an asset field which only allows <code>.svg</code>s.</p>
<p>To be more specific, I want to upload icons I can later import in my templates via the <code>svg()</code> command. Is this possible <strong>without</strong> any plugins or a custom field?</p>

<craft3><assets><svg>
Only allow SVG as file type
# Only allow SVG as file type

(Asked by: username_0 on 2020-08-27)

I want to have an asset field which only allows `.svg`s.

To be more specific, I want to upload icons I can later import in my templates via the `svg()` command. Is this possible **without** any plugins or a custom field?

**Tags:** craft3, assets, svg

---

## 1 answers

### Answer by username_1 on 2020-08-27. Score: 6 | Accepted answer

You can achieve this using the extraFileKinds config setting like this:
'extraFileKinds' => [
    'svg' => [
        'label' => 'SVG',
        'extensions' => ['svg'],
    ],
],

On your Asset field, check the "Restrict allowed file types?" checkbox, and select "SVG" from the list.


---

