templated-docs icon indicating copy to clipboard operation
templated-docs copied to clipboard

Image / ImageField not expanded correctly

Open zontarian opened this issue 7 years ago • 7 comments

  • 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

zontarian avatar Apr 24 '17 13:04 zontarian

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.

zontarian avatar Apr 24 '17 13:04 zontarian

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.

alexmorozov avatar Apr 26 '17 08:04 alexmorozov

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!

zontarian avatar Apr 26 '17 08:04 zontarian

Sure, I'll look into this as well.

alexmorozov avatar Apr 26 '17 08:04 alexmorozov

Any news on the Images bug? :)

zontarian avatar May 24 '17 08:05 zontarian

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?

jejimenez avatar Oct 17 '17 22:10 jejimenez

Hi @alexmorozov , I have the same problem with images files. Please help us. Thank

juniverjair avatar Apr 09 '19 03:04 juniverjair