Custom assets upload folder?


(Helmi) #1

Is there any default configuration to upload custom assets into the shared folder for web accessible assets like fonts?

It’s a bit weird to allow all the web font formats for uploads into the forum just to add them as assets. I thought there should be some folder in /var/discourse/shared for that.


(Joe) #2

Search for authorized_extensions in the admin settings.

You have total control over what extensions to allow as you see fit:


(Helmi) #3

sure, I was just thinking there should be a better way to upload a bunch off assets to the forum. Doing it that way is a bit of a hazzle as it renames every file on upload and it sounds a bit weird to activate all the file formats for upload that I wouldn’t allow my users to upload usually.


(Joe) #4

The only setting that would affect all users is the second one. Allowing svg uploads for staff or in themes does not mean that all users will be able to upload svg files.

I’m still unsure what your use case is. Can you share a bit more on what you’re trying to do?


(Helmi) #5

Well maybe I’m just getting it wrong? I’d like to upload a bunch (24) font files to be used in my theme. I would prefer to just upload them via sftp to a folder instead of uploading them in the forums. The way assets are uploaded to the assets topic in staff forum renames them and I need to wildly encrypt the css file for fonts instead of having clear naming. Also I need to add the fonts to “authorized extensions” that way.

I’m not sure how the ‘theme authorized extensions’ work - but maybe that’s the way it should go - where are these theme uploads?

EDIT: just ignore me - I really should have opened my eyes first :-/


(Jeff Atwood) #6

Ok so this topic can be removed then?


(Helmi) #7

well yeah I guess this is the way to do it then - it’s still a bit more awkward than I was hoping for but it looks like there’s no easy way to just put static assets in a folder.


(Joe) #8

When you upload theme assets you can assign variables to them.

You can then use the variables to call them like so (in the case of fonts)

@font-face {
  font-family: 'font';
  src: url(#{$fontWoff2}) format('woff2');
}

.foo {
  font-family: 'font';
}

(Kris) #9

Also, if you develop a theme using a git repo, you can put all your assets in an /assets folder. But you still have to assign variables for them in about.json

More details here:


(Jeff Atwood) #10

Yes, put them in a folder in an external webserver (or shared webfonts from a proper CDN). Problem solved.