5

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?

1 Answer 1

6

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.