templated-docs
templated-docs copied to clipboard
Image / ImageField not expanded correctly
- Templated-docs version: 0.3.1
- Python version: 2.7.x
- Operating System: Mac OSX 10.11
Description
While trying to expand an ImageField inside a template, we don't get the image in the resulting OpenOffice file.
What I Did
we create a Django ImageField object, and insert into the context, then we expand the template (an ODS) to another ODS. Everything is expanded (variables and objects) but not the image (sort of)
What we get
we unzip the resulting ODS, we see the image tag with the link to the subdir "Pictures/<ourfile.jpg>" but there is no "Pictures/" subdir in the resulting zip file, so this to us explains why it doesn't work as expected. We have looked at the source code of the image tag, and indeed there doesn't seem to be an instruction to write anything to the Pictures subdir.
There is something in the init.py file, that seems to write in the Pictures/ subdir but it doesn't work for us.
We are pretty ignorant of the ODT/S format, but to us it seems it could not work if there is no embedded file in the zip. Is this assumption correct? If so, could we propose a patch?
Thanks Z
Ok, we have found maybe a little typo: On line 134 of init.py
for _, image in context.dicts[0].get(IMAGES_CONTEXT_KEY, {}).items():
where
IMAGES_CONTEXT_KEY = '_templated_docs_imgs'
but for us, debugging the code, the relevant key in the context.dicts[0] is:
IMAGES_CONTEXT_KEY = 'ootemplate_imgs'
By doing this substitution we have managed to have the image written in the Pictures/ subdir. It still does not show up in the ODS file, but it seems more feasable now.
Hi, @zontarian , thanks for the report. You're right, that's just a silly typo. I'll fix it and roll out a new version.
Hi @alexmorozov, thanks! But we have another thing to ask: as we said, the problem goes away only partly: the picture is saved inside the 'Pictures/' subfolder, but in our example, it is not showing up.
By unzipping and looking at the content, we see the tag is written without any obvious mistakes, but the image does not show up. Could you please do a little test on your part also? We are using a spreadsheet at the moment.
Thanks!
Sure, I'll look into this as well.
Any news on the Images bug? :)
I'm facing the same issue, seeing in Zipped file I can see the image is properly placed, but when it creates the first odt file, it is not properly deployed. Is ther any alternative to solve the problem?
Hi @alexmorozov , I have the same problem with images files. Please help us. Thank