pqina / filepond

🌊 A flexible and fun JavaScript file upload library
https://pqina.nl/filepond
MIT License
15.25k stars 828 forks source link

[Feature] be able to setting all options using data-attributes #904

Open donnykurnia opened 1 year ago

donnykurnia commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe.

The documentation shows that filepond can read options from the data attributes. I also use similar features for datatables and select2. So initially I thought this will be the same in filepond. It turns out, it's not. In datatables, I'm using data-order='[[1, "asc"]]' and it's working. For filepond, I try using data-accepted-file-types='["image/*"]' but it didn't work.

After reading the filepond source code, I found that filepond will convert the string value of the options. So now I can make this work using data-accepted-file-types="image/*" instead.

I want to know, is it possible to pass all the options only using data-attributes? I tried to use it for server settings, but so far I cannot make it work.

Describe the solution you'd like

The documentation of filepond only covers the limited example for passing the options from data-attributes. I've tried to search the issues, StackOverflow, but only find unrelated code samples. The vue-filepond code sample is also limited, only shows the simple server prop, but didn't show the advanced server setting.

If passing options using only data-attributes is possible, especially for the server option, then please add more sample code to show this capability. Perhaps each option's explanation in the documentation will show the js code and the alternative code, using only data-attributes.

Describe alternatives you've considered

I'm ready to help to update the documentation if this feature is already possible. I am also ready to help implements the features to filepond so all the filepond options can be passed from data-attributes.

rikschennink commented 1 year ago

To answer your question, it's not possible to use this for all options.