File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -48,12 +48,16 @@ def display(self):
4848 from IPython .display import Image , display
4949
5050 if self .uri :
51- if self .mime_type .startswith ('audio' ):
51+ if self .mime_type .startswith ('audio' ) or self . uri . startswith ( 'data:audio/' ) :
5252 uri = _convert_display_uri (self .uri , self .mime_type )
5353 _html5_audio_player (uri )
54- elif self .mime_type .startswith ('video' ):
54+ elif self .mime_type .startswith ('video' ) or self .uri .startswith (
55+ 'data:video/'
56+ ):
5557 uri = _convert_display_uri (self .uri , self .mime_type )
5658 _html5_video_player (uri )
59+ elif self .uri .startswith ('data:image/' ):
60+ _html5_image (self .uri )
5761 else :
5862 display (Image (self .uri ))
5963 elif self .tensor is not None :
@@ -86,6 +90,18 @@ def _convert_display_uri(uri, mime_type):
8690 return uri
8791
8892
93+ def _html5_image (uri ):
94+ from IPython .display import display
95+ from IPython .core .display import HTML # noqa
96+
97+ src = f'''
98+ <body>
99+ <image src="{ uri } " height="200px">
100+ </body>
101+ '''
102+ display (HTML (src )) # noqa
103+
104+
89105def _html5_video_player (uri ):
90106 from IPython .display import display
91107 from IPython .core .display import HTML # noqa
You can’t perform that action at this time.
0 commit comments