def image node
target = node.attr 'target'
width_attr = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : nil
height_attr = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : nil
if ((node.attr? 'format', 'svg', false) || (target.include? '.svg')) && node.document.safe < SafeMode::SECURE &&
((svg = (node.option? 'inline')) || (obj = (node.option? 'interactive')))
if svg
img = (read_svg_contents node, target) || %(<span class="alt">#{node.alt}</span>)
elsif obj
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri(node.attr 'fallback')}" alt="#{encode_quotes node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>) : %(<span class="alt">#{node.alt}</span>)
img = %(<object type="image/svg+xml" data="#{node.image_uri target}"#{width_attr}#{height_attr}>#{fallback}</object>)
end
end
img ||= %(<img src="#{node.image_uri target}" alt="#{encode_quotes node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>)
if node.attr? 'link'
window_attr = %( target="#{window = node.attr 'window'}"#{window == '_blank' || (node.option? 'noopener') ? ' rel="noopener"' : ''}) if node.attr? 'window'
img = %(<a class="image" href="#{node.attr 'link'}"#{window_attr}>#{img}</a>)
end
id_attr = node.id ? %( id="#{node.id}") : nil
classes = ['imageblock', node.role].compact
class_attr = %( class="#{classes * ' '}")
styles = []
styles << %(text-align: #{node.attr 'align'}) if node.attr? 'align'
styles << %(float: #{node.attr 'float'}) if node.attr? 'float'
style_attr = styles.empty? ? nil : %( style="#{styles * ';'}")
title_el = node.title? ? %(\n<div class="title">
%(<div#{id_attr}#{class_attr}#{style_attr}>
<div class="content">
#{img}
</div>#{title_el}
</div>)
end