Skip to content

How to show only certain mime types from configuration? #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jstnthms opened this issue Dec 4, 2015 · 5 comments
Closed

How to show only certain mime types from configuration? #193

jstnthms opened this issue Dec 4, 2015 · 5 comments

Comments

@jstnthms
Copy link

jstnthms commented Dec 4, 2015

I see there is an option to set the visible mime types from the client side, and I know I can restrict the uploadable mime types from the configuration, but I don't see how I can set the visible mime types from configuration.

Is overriding the ElFinder Controller and templates my only option right now?

Assuming there is no way to set the visible mime types through the configuration, it would be nice to be able to do something like this:

fm_elfinder:
    instances:
        default:
            # ...
            connector:
                # ...
                roots:
                    uploads:
                        # ...
                        upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                        visible_mime_types: [] # defaults to value of upload_allow

then ElFinderController would pass along a template variable called mimeTypes, set to the value of visible_mime_types.

$('.elfinder').elfinder({
    // ...
    mimeTypes: mimeTypes,
    // ...
});

It would be a whole lot cleaner than having to override the controller and several templates. Plus, if you are restricting the uploadable types, you probably want to restrict the visible types the same way. Specifically, for inserting images into a wysiwyg, or if you have a file select field for PDFs only, etc.

@helios-ag
Copy link
Owner

Hi @jstnthms, do you willing to make PR?

@jstnthms
Copy link
Author

jstnthms commented Dec 7, 2015

Edit: my solution isn't exactly correct. I had the variable visible_mime_types at the roots level, but it can only be applied per instance. So the config should actually look something like this:

fm_elfinder:
    instances:
        default:
            # ...
            visible_mime_types: ['image'] # defaults to empty array
            # ...

Should I still make a PR?

@helios-ag
Copy link
Owner

Why not, i will accept it 👍

@jstnthms
Copy link
Author

jstnthms commented Dec 7, 2015

For continuity, pull request is here: #195

@helios-ag
Copy link
Owner

merged and tagged as 6.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants