TransWikia.com

Only allow SVG as file type

Craft CMS Asked by user11054 on January 2, 2021

I want to have an asset field which only allows .svgs.

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?

One 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.

Correct answer by André Elvan on January 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP