Closed vbroskas closed 4 years ago
Right now I'm thinking I need to use Django custom template tags to make a function with the preview-generator code inside it. The function will take in the file name which I then use in: file_to_preview_path = f"/tmp/{file_name}.pdf"
Django custom template tags worked
Hi @vbroskas could you give a code snippet? It would be interesting for other django developers.
The template tag function is working but I'm having an issue with getting the preview image to work.
Preview-generator returns a path to the image, but I need the URL for the image so I can display it in a template. Once I figure out how to do this I'll post some snippets.
Apologies since I know this is simple, but I'm not just understanding correctly. I have a simple stream block for letting a user upload multiple files which are then all looped through and displayed in a page template:
In order to implement preview-generator I need the path of the file I want a thumbnail for. However, I only have access to the file url in the template after a file has actually been uploaded. I'm confused about where to put this code:
It seem like I need to put it in the template since that is where I have
{{doc.related_document.url}}
, which can be put here:file_to_preview_path = '/tmp/an_image.png'
Thanks for any guidance you can give!