Use inline svg for solid map key images
This commit is contained in:
parent
0c472ad198
commit
f92183e520
2 changed files with 5 additions and 6 deletions
|
@ -1,8 +1,7 @@
|
|||
module SvgHelper
|
||||
def solid_svg_image_tag(width, height, fill, **options)
|
||||
svg = "<svg xmlns='http://www.w3.org/2000/svg' width='#{width}' height='#{height}'>" \
|
||||
"<rect width='100%' height='100%' fill='#{fill}' />" \
|
||||
"</svg>"
|
||||
image_tag "data:image/svg+xml,#{u(svg)}", **options
|
||||
def solid_svg_tag(width, height, fill, **options)
|
||||
tag.svg :width => width, :height => height, **options do
|
||||
tag.rect :width => "100%", :height => "100%", :fill => fill
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<%= tag.tr :class => "mapkey-table-entry", :data => { :layer => layer_name, :zoom_min => entry["min_zoom"], :zoom_max => entry["max_zoom"] } do %>
|
||||
<td>
|
||||
<% if entry["width"] && entry["height"] && entry["fill"] %>
|
||||
<%= solid_svg_image_tag entry["width"], entry["height"], entry["fill"], :class => "d-block mx-auto" %>
|
||||
<%= solid_svg_tag entry["width"], entry["height"], entry["fill"], :class => "d-block mx-auto" %>
|
||||
<% else %>
|
||||
<%= image_tag "key/#{layer_name}/#{entry['image']}", :class => "d-block mx-auto" %>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue