Skip to content

Commit

Permalink
Checking type of image first
Browse files Browse the repository at this point in the history
  • Loading branch information
mikael frosini committed Nov 30, 2020
1 parent 337bb99 commit a03fb2e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ipyplot/_html_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _create_img(
img_html += '<h4 style="font-size: 12px; word-wrap: break-word;">%s</h4>' % str(custom_text) # NOQA E501

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

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

html = """
<div class="ipyplot-placeholder-div-%(0)s">
Expand Down

0 comments on commit a03fb2e

Please sign in to comment.