Fileupload (Filepond) custom preview
Can anyone nudge me in the right direction for this? (I'm not hoping for a solution, just a general "how I might go about this")..
So when you upload a png or jpg for example, FilePond gives you a preview of the image. But if I upload a PDF or word document, I want to show a custom icon (I have these already) of a file with the PDF logo on, etc. instead of just a block of green or grey.
I'm guessing this is custom javascript, but how do I access these properties in the context of Filament? And get Filament to understand how to render the Filepond file with the custom icon of my choosing?
(I hope that makes sense).
I'm open to SpatieMedia or other 3rd party solutions also, if that's more appropriate for this?
Also, when I hit cancel after saving an uploaded file, I get stuck in an infinite loop of it loading the same "edit" page.. Is that a bug? Or do I need a custom "exit" button?
8 Replies
As a workaround, I might just add a dynamic read-only "icon" field somehow, that displays the relevant icon next to the upload (which I can easily manage in PHP).
Any filepond preview plugins would be useful too, if anyone knows any? I tried: "npm install filepond-plugin-pdf-preview" but that doesn't seem to do anything.
i think we do have the pdf preview plugin installed by default, right?
Thanks for responding, Dan. It doesn't seem to create a preview for me when I upload a PDF document. Are there any other required server dependencies? Imagemagick etc.?
I was also angling this question towards - if a preview cannot be created (e.g. for an unknown/unsupported file type), can we set a default "no preview" display of some kind?
Ah right, I think we must have tried to integrate it then and it conflict with one of our other plugins, sorry about that
I'm not sure how to approach a No Preview display, you'd need to learn how to build Filepond plugins
Thanks, Dan. I expect it’ll be some JavaScript additions. I’ll share here once I figure out a successful technique.
Actually, I'm talking horse mess. PDF previews are actually displaying - sorry for any confusion.
oh? nice
hi @benshawuk I don't think pdf preview plugin is installed by default...
Indeed, you’re correct. The browser was adding to my confusion as safari is able to preview them natively.