nbconvert: attached image in ipynb not shown in html
image_test.ipynb.zip
I tried converting this simple notebook with
python -m nbconvert docs/notebooks/image_test.ipynb
running nbconvert 5.3.1 . The notebook contains one markdown cell with a single line

But the image does not show up in the resulting html, only a cell with text ‘image.png’ in it.
(attachment:image.png). The image works in the notebook so it seems correctly embedded. Is this not supported? It’s an important feature for me so any help would be really useful.
Thanks in advance
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 29
- Comments: 19 (5 by maintainers)
Have wrapped it together so anybody can immediately use it:
ipy2html.py.gz
For what it’s worth, fixing up the HTML post-conversion manually is also pretty straightforward: Assuming that all attachment filenames are unique, you could do something like
Of course, this does nothing to actually fix the bug. Without being able to claim much of an overview of how rendering occurs, it seems like you would want to somehow take this into account in the filter
nbconvert.html.HTMLExporter.markdown2html
(which does not see theNotebookNode
itself, but if you don’t mind adding this as state, you could do so infrom_notebook_node
).Hello guys. Thanks for your workaround code snippets.
I slightly changed @platise’s code which can handle multiple non-unique attachments.
The usage is same.
ipy2html.py
I needed this, so I wrote a pre-processor to extract attached images and put them in the
outputs
, which is used for images in the output part of a code cell.It has been working well for me.
https://gist.github.com/sglyon/5687b8455a0107afc6f4c60b5f313670
Thanks @imcomking for upgrade, works well! and also handles exports where Embedded HTML doesn’t work, with ref to @tonycpsu
No problem.
My usage was as follows