Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image / ImageField not expanded correctly #13

Open
zontarian opened this issue Apr 24, 2017 · 7 comments
Open

Image / ImageField not expanded correctly #13

zontarian opened this issue Apr 24, 2017 · 7 comments

Comments

@zontarian
Copy link

zontarian commented Apr 24, 2017

  • 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
Copy link
Author

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.

@alexmorozov
Copy link
Owner

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.

@zontarian
Copy link
Author

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!

@alexmorozov
Copy link
Owner

Sure, I'll look into this as well.

@zontarian
Copy link
Author

Any news on the Images bug? :)

@jejimenez
Copy link

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?

@juniverjair
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants