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.attr 'alt'}</span>)
elsif obj
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri(node.attr 'fallback')}" alt="#{node.attr 'alt'}"#{width_attr}#{height_attr}#{@void_element_slash}>) : %(<span class="alt">#{node.attr '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="#{node.attr 'alt'}"#{width_attr}#{height_attr}#{@void_element_slash}>)
if (link = node.attr 'link')
img = %(<a class="image" href="#{link}">#{img}</a>)
end
id_attr = node.id ? %( id="#{node.id}") : nil
classes = ['imageblock', node.style, 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