Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Mime Type otf / ttf

Started by Pierre Causse 3 years ago · 5 replies · 1354 views
3 years ago

Hello Everyone,
I'm trying to allow my client to upload a otf or ttf file in its article, but I can't make it work.
I always get the error "The mime type does not match to file extension".
I've already tried to add in media.yaml :

YAML
  otf:
    type: file
    thumb: media/thumb-json.png
    mime: font/otf
  ttf:
    type: file
    thumb: media/thumb-json.png
    mime: font/ttf

Any idea how I could make this work ? : /

3 years ago

Does nobody know what I could do ? : /
In the documentation, after adding a new mime (for example here, ical) type they say

Then all you need to do is provide the appropriate .ical.twig template to render any file you request of this type.

Should I do something like this for otf and ttf ? And how ?

3 years ago

I managed to make ttf work, but otf still won't work. I check in terminal locally which mime type was my otf and ttf file, and it was font/sfnt for ttf and application/vnd.ms-opentype for otf. It solved it for ttf but otf didn't work. My question also is, is a mime type always the same on all computers ? Meaning, will a otf always be "application/vnd.ms-opentype" ? And if so, why is mime type for otf in online doc is always "font/otf" ?

3 years ago

Hi, @edi0th, try using application/octet-stream, probably in both cases, that should solve your issue.

YAML
  otf:
    type: file
    thumb: media/thumb.png
    mime: application/octet-stream
    image: null
3 years ago

🤔 I tested on localhost and it worked fine + it was the only mime type that allowed fonts to be loaded through the admin

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago