Fix #2763, add default alt attribute to svg images

Add uri as default alt attribute to images in svg format
This commit is contained in:
mixmastamyk 2016-07-08 18:26:42 -07:00 committed by GitHub
parent 3807eda6df
commit edfdd3ec78

View File

@ -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('<div align="%s" class="align-%s">' %
(node['align'], node['align']))