How to allow files .lottie on Kirby

Hello, I am trying to enable the use of .lottie files on Kirby.

While I could find some information here:

and tried to create the plugin like:

<?php

Kirby::plugin('frankwords/lottie-file-support', [
    'fileTypes' => [
        'lottie' => [
            'mime' => 'application/json',
            'type' => 'lottie',
        ],
    ]
]);

I still not being able to upload the files or make them recognisable. I guess I didn’t understand properly how to use or create that plugin.

Together with the plugin I create the following file blueprint:

title: Allow dotLottie file

accept:
  mime: application/json
  extension: lottie

and allowed it on uploads on my block blueprint:

uploads: allow-lottie

No success yet.

How effectively do it?

How to structure the plugin etc?

Thanks a lot

The type can be one of audio , code , document , image and video.
I guess you would choose code or video.

In your file blueprint, having both mime and extension as options causes the panel to show a “file open” dialog which accepts all the file extensions the browser knows as application/json (those would probably only be .json files), so the browser wouldn’t allow you to select .lottie files.

The best option you have now would be to do:

title: Allow dotLottie file

accept:
  mime: *
  extension: lottie

This allows the browser to select any files (.lottie, and everything else, included), and on upload it’s verified if it’s actually a .lottie file (an error would be shown otherwise).


It’s not ideal, and there is currently some work underway to make this better. In future versions, you will probably be able to upload custom file formats simply by writing:

accept:
  extension: lottie
1 Like

.lottie files are actually just zip-files with a different extension. For my last project for Brückner+Brückner I could simply add mime: application/zip and that worked.

Hello @rasteiner,

thanks a lot for your answer. Unfortunately the solution didn’t work. I tried both

accept:
  extension: lottie
  mime: *

and also

accept:
  extension: lottie
  mime: application/zip 

sure I also tried application/json.

By trying mime: * I get the error below, that’s what made me try application/zip

screen 2024-02-13 at 12.18.14

Do you think it can be anything about my plugin? Or maybe Kirby don’t accept .lottie at all?

<?php

Kirby::plugin('frankwords/lottie-file-support', [
    'fileTypes' => [
        'lottie' => [
            'mime' => 'application/zip',
            'type' => 'code',
        ],
    ]
]);

Thanks again

I have no further explanation for this then, it worked fine on Kirby 3.x with simply specifying the blueprint, no need for adding a file type.

At this point I’d delete the plugin, and just write:

accept:
  extension: lottie

don’t specify a mime type (not even mime: "*").

1 Like

fyi, as far as I know, this doesn’t work on Windows. Windows uses only the file extension to determine the file type. So if you write accept: application/zip only files ending in .zip will be selectable.

MacOs also keeps other metadata for files (like the mime type of downloaded files, or creator codes when generating files locally). While Linux sniffs the content.
That’s probably why it worked for you.

I added both the extension and mime time, but yeah, that was on macOS. The client is the same and never mentioned anything ^^

Yeah, in regards to the file dialog, the extension option is ignored when there’s a mime type specified.

1 Like

@rasteiner @tobimori Thank you for the answers.

Totally removing the plugin and making my blueprint just like below actually worked. Kind of surprising.

I am also using MacOs.

accept:
  extension: lottie