diff --git a/webapp_post.py b/webapp_post.py
index 6b00a93f..d2bad961 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -202,6 +202,14 @@ def getAvatarImageUrl(session,
return avatarUrl
+def getBrokenLinkSubstitute(iconsPath: str) -> str:
+ """Returns html used to show a default image if the link to
+ an image is broken
+ """
+ return " onerror=\"this.onerror=null; this.src='" + \
+ iconsPath + "/avatar_default.png'\""
+
+
def getAvatarImageHtml(showAvatarOptions: bool,
nickname: str, domainFull: str,
avatarUrl: str, postActor: str,
@@ -210,18 +218,13 @@ def getAvatarImageHtml(showAvatarOptions: bool,
iconsPath: str) -> str:
"""Get html for the avatar image
"""
- # if the image link is broken then this provides a local substitute
- brokenLinkSubstitute = \
- " onerror=\"this.onerror=null; this.src='" + \
- iconsPath + "/avatar_default.png'\""
-
avatarLink = ''
if '/users/news/' not in avatarUrl:
avatarLink = ' '
avatarLink += \
' \n'
+ getBrokenLinkSubstitute(iconsPath) + '/>\n'
if showAvatarOptions and \
domainFull + '/users/' + nickname not in postActor:
@@ -234,14 +237,14 @@ def getAvatarImageHtml(showAvatarOptions: bool,
'
\n'
+ getBrokenLinkSubstitute(iconsPath) + '/>\n'
else:
# don't link to the person options for the news account
avatarLink += \
'
\n'
+ getBrokenLinkSubstitute(iconsPath) + '/>\n'
return avatarLink.strip()
@@ -772,10 +775,6 @@ def getPostTitleAnnounceHtml(baseDir: str,
if announceAvatarUrl:
idx = 'Show options for this person'
if '/users/news/' not in announceAvatarUrl:
- brokenLinkSubstitute = \
- " onerror=\"this.onerror=null; this.src='" + \
- iconsPath + "/avatar_default.png'\""
-
replyAvatarImageInPost = \
' ' \
'