Display an empty img if a site icon can't be found

This improves the search result icon feature by "hiding" the site's icon
if one was not found. This happens in scenarios where a site doesn't
have a /favicon.ico due to having a unique path or using javascript to
load the icon.
pull/1085/head
Ben Busby 7 months ago
parent 4292ec7f63
commit 67b6110087
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1

@ -490,7 +490,13 @@ def element():
return send_file(io.BytesIO(empty_gif), mimetype='image/gif')
try:
file_data = g.user_request.send(base_url=src_url).content
response = g.user_request.send(base_url=src_url)
# Display an empty gif if the requested element couldn't be retrieved
if response.status_code != 200:
return send_file(io.BytesIO(empty_gif), mimetype='image/gif')
file_data = response.content
tmp_mem = io.BytesIO()
tmp_mem.write(file_data)
tmp_mem.seek(0)

Loading…
Cancel
Save