Closed lukepass closed 4 years ago
Encoding is only for sending files to the server. To preview local files you can do this:
FilePond.create({
server: {
load: (src, load) => {
fetch(fileSrc).then(res => res.blob()).then(load);
}
}
})
Thanks @rikschennink, this is almost working for me. I have the following starting files
property:
[
{options: {type: "local"}, source: 672}, // this is for FilePond.create
{options: {type: "local"}, source: 673} // this is for FilePond.create
]
But since I don't implement the fetch method (I don't use server
property at all thanks to FilePondPluginFileEncode
) I need a method to get the URL to preview. I tried something like this:
[
{options: {type: "local"}, source: {id: 672, url: 'mypreview.jpg'}}, // this is for FilePond.create
{options: {type: "local"}, source: {id: 673, url: 'mypreview2.jpg'}}, // this is for FilePond.create
]
And then:
load: function(source, load) {
fetch(source.url).then((res) => res.blob()).then(load);
},
But this is not working and giving me an error about "split". Maybe the source property can only be a string and not a complex object?
Thanks!
You could use the file-poster plugin? https://pqina.nl/filepond/docs/patterns/plugins/file-poster/
Exactly what I was looking for, really thank you!
@lukepass fantastic, I'll close the issue then 👍
@rikschennink sorry one last question, when using FilePoster
the image is always very big. The previewer plugin instead is able to detect dimensions. How can I specify them with poster plugin?
I tried adding width and height (not documented, I just tried) but it didn't work.
Thanks!
EDIT: it seems related to these:
The post will always take up the entire item, at the moment that's the way it's designed.
The post will always take up the entire item, at the moment that's the way it's designed.
That's unfortunate and unhelpful. How can we achieve the same functionality with ImagePreview?
Update: There are new props added.
filePosterHeight filePosterMinHeight filePosterMaxHeight
see here thanks @fratzinger
Hello, how can I add a file preview when using
FilePondPluginFileEncode
? I don't have server side methods and so when I am loading the initial files they cannot be loaded using theload
method. Can I provide thepreviewUrl
manually?Thanks!