Skip to content

Commit be77c42

Browse files
authored
add width to css for FloatImage (#1570)
* add width to css for FloatImage Allows for setting relative size of an image without changing default behavior, fixes #1001 imo... * forgot to declare in __init__ ok, my bad that was extremely careless... I hope it passes this time * added style test template update asserts a 20% image width
1 parent 67aab11 commit be77c42

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

folium/plugins/float_image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class FloatImage(MacroElement):
1212
position:absolute;
1313
bottom:{{this.bottom}}%;
1414
left:{{this.left}}%;
15+
width:{{this.width}}%;
1516
}
1617
</style>
1718
{% endmacro %}
@@ -24,9 +25,10 @@ class FloatImage(MacroElement):
2425
{% endmacro %}
2526
""")
2627

27-
def __init__(self, image, bottom=75, left=75):
28+
def __init__(self, image, bottom=75, left=75, width=100):
2829
super(FloatImage, self).__init__()
2930
self._name = 'FloatImage'
3031
self.image = image
3132
self.bottom = bottom
3233
self.left = left
34+
self.width = width

tests/plugins/test_float_image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def test_float_image():
1414
m = folium.Map([45., 3.], zoom_start=4)
1515
url = 'https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png'
16-
szt = plugins.FloatImage(url, bottom=60, left=70)
16+
szt = plugins.FloatImage(url, bottom=60, left=70, width=20)
1717
m.add_child(szt)
1818
m._repr_html_()
1919

@@ -35,6 +35,7 @@ def test_float_image():
3535
position:absolute;
3636
bottom:60%;
3737
left:70%;
38+
width:20%;
3839
}
3940
</style>
4041
""")

0 commit comments

Comments
 (0)