Skip to content

Commit a03fb2e

Browse files
author
mikael frosini
committed
Checking type of image first
1 parent 337bb99 commit a03fb2e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

ipyplot/_html_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def _create_img(
274274
img_html += '<h4 style="font-size: 12px; word-wrap: break-word;">%s</h4>' % str(custom_text) # NOQA E501
275275

276276
use_b64 = True
277-
inline_svg = (inline_svg and image[-4:]==".svg")
277+
inline_svg = (inline_svg and isinstance(img,str) and image[-4:]==".svg")
278278
if inline_svg:
279279
use_b64 = False
280280
# if image is a string (URL) display its URL
@@ -293,8 +293,8 @@ def _create_img(
293293
img_html += '<img src="data:image/png;base64,%s"/>' % _img_to_base64(image, width) # NOQA E501
294294

295295
if inline_svg:
296-
string = urllib.parse.quote(open(image,'r').read())
297-
img_html += f'<img src="data:image/svg+xml,{string:s}">'
296+
svg_url = urllib.parse.quote(open(image,'r').read())
297+
img_html += f'<img src="data:image/svg+xml,{svg_url:s}">'
298298

299299
html = """
300300
<div class="ipyplot-placeholder-div-%(0)s">

0 commit comments

Comments
 (0)