diff --git a/IPython/core/display.py b/IPython/core/display.py index 9035abd..ad3b220 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -422,7 +422,7 @@ class Image(DisplayObject): _read_flags = 'rb' - def __init__(self, data=None, url=None, filename=None, format=u'png', embed=False): + def __init__(self, data=None, url=None, filename=None, format=u'png', embed=None): """Create a display an PNG/JPEG image given raw data. When this object is returned by an expression or passed to the @@ -441,10 +441,24 @@ class Image(DisplayObject): The format of the image data (png/jpeg/jpg). If a filename or URL is given for format will be inferred from the filename extension. embed : bool - Should the image data be embedded in the notebook using a data URI (True) - or be loaded using an tag. Set this to True if you want the image - to be viewable later with no internet connection. If a filename is given - embed is always set to True. + Should the image data be embedded using a data URI (True) or be + loaded using an tag. Set this to True if you want the image + to be viewable later with no internet connection in the notebook. + + Default is `True`, unless the keyword argument `url` is set, then + default value is `False`. + + Note that QtConsole is not able to display images if `embed` is set to `False` + + Examples + -------- + # embed implicitely True, works in qtconsole and notebook + Image('http://www.google.fr/images/srpr/logo3w.png') + + # embed implicitely False, does not works in qtconsole but works in notebook if + # internet connexion availlable + Image(url='http://www.google.fr/images/srpr/logo3w.png') + """ if filename is not None: ext = self._find_ext(filename) @@ -460,7 +474,7 @@ class Image(DisplayObject): if ext == u'png': format = u'png' self.format = unicode(format).lower() - self.embed = True if filename is not None else embed + self.embed = embed if embed is not None else (url is None) super(Image, self).__init__(data=data, url=url, filename=filename) def reload(self):