Nbconvert: Attached image not exported if referenced from <img> tag

Created on 30 Jun 2019  路  5Comments  路  Source: jupyter/nbconvert

I know of https://github.com/jupyter/nbconvert/issues/699. Nevertheless I find it confusing because I can easily export to html or reveal.js and the images are there as far as I reference them using ![]() syntax. Now, as this is very limited in terms of formatting, many times I need to use an <img> tag instead, and then the attachments aren't exported to the output.

  1. Take a screenshot, copy & paste it into some notebook cell.
  2. Download the notebook as html or reveal.js: ok, the image is still there.
  3. Replace the markdown image syntax by the corresponding html syntax, referencing the same url (for example, "attachment:image.png").
  4. Render the cell: ok, the image is still there.
  5. Download the notebook as html or reveal.js: the image has disappeared!


Nbconvert version: 5.5.0

Most helpful comment

I solved it by adding the images in the correct path (relative to my html files) used in the <img> tags.

All 5 comments

Same issue here. I usually use <img> for better image formatting. Hopefully nbconvert can support it.

I solved it by adding the images in the correct path (relative to my html files) used in the <img> tags.

Yes it likely is related. The way attachments got implemented in notebooks was fairly organic and this caused some difficult-to-fix issues for exporting to other formats. @xiaohk is the best work-around for now until that code path gets cleaned up (likely a 6.0 feature).

I tried a lot of workarounds too, and eventually ended up with the same thing that @xiaohk described.

I solved it by adding the images in the correct path (relative to my html files) used in the <img> tags.

@xiaohk
Can you explain how to do this, using a concrete example?

Does it apply to my situation, where I have a MarkDown cell with an attached image, shown via MarkDown syntax (not an HTML <img> tag; not an external image file).

I also tried nbconvert with an image that is embedded through data: and een encoded image. This also did not work for me.

Was this page helpful?
0 / 5 - 0 ratings