diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 7b666aa52..5558b7fec 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -458,15 +458,14 @@ class HTMLTranslator(BaseTranslator): node['uri'] = posixpath.join(self.builder.imgpath, self.builder.images[olduri]) - if node['uri'].lower().endswith('svg') or \ - node['uri'].lower().endswith('svgz'): - atts = {'src': node['uri']} + uri = node['uri'] + if uri.lower().endswith('svg') or uri.lower().endswith('svgz'): + atts = {'src': uri} if 'width' in node: atts['width'] = node['width'] if 'height' in node: atts['height'] = node['height'] - if 'alt' in node: - atts['alt'] = node['alt'] + atts['alt'] = node.get('alt', uri) if 'align' in node: self.body.append('
' % (node['align'], node['align']))