[IPython-User] Ipython Notebook : local url insertion

MinRK benjaminrk@gmail....
Sat Oct 15 03:35:12 CDT 2011


I don't believe that's possible. It could be a pretty big security
issue if websites were allowed to load pages with arbitrary content
from the browser's filesystem.

Note that you can get an image from the kernel's filesystem with code:

from IPython.core.display import Image
Image(filename='/path/to/image.png')

Of course, it is likely that the kernel's filesystem and the browser's
are the same, in which case kernel code and the client have access to
the same stuff, but that isn't necessarily true.  And markdown cells
are purely browser-rendered, they involve zero server communications
at all, which also means that you are protected from code generated in
markdown just like you are from HTML/javascript on any normal website
(for better or worse).

Now, if you *really* needed it to be in the markdown cell, here's a
dirty trick that I just tested, and does technically work:

1. draw the image from the code above
2. right-click the resulting image and copy its url (it's a data-url
of the b64-encoded image data)
3. add <img src="<PASTE>"/> to your markdown cell

Now, depending on the size of your image, that will be one great big
line in your markdown cell.

-MinRK


More information about the IPython-User mailing list