From edfdd3ec786d2b39ab04ad39d7bf154a2fa13f3c Mon Sep 17 00:00:00 2001 From: mixmastamyk Date: Fri, 8 Jul 2016 18:26:42 -0700 Subject: [PATCH] Fix #2763, add default alt attribute to svg images Add uri as default alt attribute to images in svg format --- sphinx/writers/html.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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']))