Skip to content
Snippets Groups Projects
Commit cf51440b authored by Greg Wilson's avatar Greg Wilson
Browse files

Making the code a little more robust

parent 466c28db
Branches
Tags
No related merge requests found
......@@ -58,7 +58,8 @@ def find_image_nodes(doc, result):
if (doc['type'] == 'img') or \
((doc['type'] == 'html_element') and (doc['value'] == 'img')):
result.append({'alt': doc['attr']['alt'], 'src': doc['attr']['src']})
alt = doc['attr'].get('alt', '')
result.append({'alt': alt, 'src': doc['attr']['src']})
else:
for child in doc.get('children', []):
find_image_nodes(child, result)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment