Unknown $file->type() is not "unknown"

The cheat sheet for $file->type() says that it “Returns the file type (image, document, video, archive, code, audio, unkown [sic])”, but all I get for unknown files is… well, nothing.

Bug, or wrong documentation?

Wrong or at least not clear documentation. unknown should be null in this case.

Yeah, talked to Bastian about it. Said the same thing. :​) He said he’d fix the documentation to be clearer.


Is it possible to extend and add new file types to this list?

for example—

Fonts: “otf”, “ttf”, “woff”, woff2", "eot"
Sketch: “sketch”


f::$types['document'][] = 'sketch';

You can also add an entirely new category:

f::$types['font'] = array('otf', 'ttf', 'woff', 'woff2', 'eot');

Wow, amazing. Would I put this in my config file?

looks like you’re able to add the sketch extension to the document file type.
You’re creating a new type called font with new extensions.

Is it also possible to remove a file type from a category?

Can SVG exist in the font type category as well as the image type category?

Either that or into a plugin. Whatever makes sense for you. Kirby will automatically pick the changes up in any code that runs after that.

That is exactly right.

Yes. The f::$types variable is a normal array, so you can modify it with the standard PHP functions.

Well, it can, but it won’t make any sense. If you call $file->type(), Kirby will return the first match. It can’t return both matches.

1 Like

Thanks so much for your detailed response, can’t wait to refactor everything :smile: