OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.44k stars 2.4k forks source link

Feature request: New settings for media file picker to filter files #4998

Open DariuS231 opened 4 years ago

DariuS231 commented 4 years ago

It would be nice to have a setting for the Media Field to filter files.

e.g.: only allow "image/png, image/jpeg" files. will translate into:

<input id="ContentPart_LogicAppTemplate-field-file-upload" type="file" name="files" multiple="multiple" accept="image/png, image/jpeg">
hishamco commented 4 years ago

I think it was there, but removed for a reason

/cc @deanmarcussen

deanmarcussen commented 4 years ago

There isn't a setting for the field as such.

Instead we use an AllowedFileExtensions setting for the media app, allowing you to change which files can be uploaded to the media app.

See the end of this doc. https://orchardcore.readthedocs.io/en/dev/docs/reference/modules/Media/

The MediaField could have a custom editor option to restrict a particular field to specific files only, but I think the AllowedFileExtensions should be enough for most users.

hishamco commented 4 years ago

@DariuS231 seems this answer your question

DariuS231 commented 4 years ago

@hishamco @deanmarcussen Not really, I was aware of AllowedFileExtensions but that is not what I was talking about.

What I meant was to limit the media file to only accept the specified type of files.

e.g.: Only allow users from uploading .gif files. they wouldn't be able to select it or if they drag and drop, they would see an error message.

hishamco commented 4 years ago

What I meant was to limit the media file to only accept the specified type of files

AllowedFileExtensions will allow you to do such this

DariuS231 commented 4 years ago

but in a global context, What about a particular field? I want other field to accept all kinds of files.

hishamco commented 4 years ago

Frankly I didn't try it, so I will reopen this again

sebastienros commented 4 years ago

The requirement makes sense. Could be a setting for the default editor.

hishamco commented 4 years ago

What if we use AllowedFileExtensions directly in the media field?

DariuS231 commented 4 years ago

That would imply a setting entry per file field would be required in the config file. Wouldn't that be awkward?

DariuS231 commented 4 years ago

What I had in mind was to add a new setting to the field editor and will then render the File Input accordingly.

hishamco commented 4 years ago

That's what Seb suggested above

deanmarcussen commented 4 years ago

Yes exactly that @DariuS231

It would be a setting on the field and as a default setting is probably best as it would then work for both normal media field and attached.

Two settings. One bool restrict file types. The next a select for which file types to accept. The vue multiselect editor would give good for this. It should take it’s possible values from the AllowedFileExtensions

hishamco commented 4 years ago

Two settings.

I think by setting the AllowedFileExtensions to accept property will restrict the file types

deanmarcussen commented 4 years ago

Another useful feature here would be to have a setting to restrict which folders (or the default folder that is opened) the user can select from.

e.g. /seo-images or /video-content

Makes it easy to handle organising media, and directing users to the correct media folder.

hishamco commented 4 years ago

I like it Dean, you remind me with a CMS that I developed few years ago where I have notion of Media Libraries, so the media can pick up from a specified library, also what you mentioned is good for organization and security point of views

rserj commented 3 years ago

We use MediaPicker field in order to pick icon files for MenuItem, it will be nice having the ability to filter by file type. Any updates on this ticket?

sebastienros commented 3 years ago

@rserj still open, feel free to implement it as a setting of the field.