Default to jpg cached avatars

main2
Bob Mottram 2019-10-18 10:00:16 +01:00
parent bbb544f373
commit b79703dbfd
2 changed files with 9 additions and 4 deletions

View File

@ -1092,7 +1092,9 @@ class PubServer(BaseHTTPRequestHandler):
elif mediaFilename.endswith('.gif'): elif mediaFilename.endswith('.gif'):
self._set_headers('image/gif',len(mediaBinary),cookie) self._set_headers('image/gif',len(mediaBinary),cookie)
else: else:
self._404() # default to jpeg
self._set_headers('image/jpeg',len(mediaBinary),cookie)
#self._404()
return return
tries=0 tries=0
while tries<5: while tries<5:

View File

@ -109,15 +109,18 @@ def getPersonAvatarUrl(baseDir: str,personUrl: str,personCache: {}) -> str:
if personJson: if personJson:
# get from locally stored image # get from locally stored image
actorStr=personJson['id'].replace('/','-') actorStr=personJson['id'].replace('/','-')
avatarImageFilename=baseDir+'/cache/avatars/'+actorStr+'.png' avatarImagePath=baseDir+'/cache/avatars/'+actorStr
avatarImageFilename=avatarImagePath+'.png'
if os.path.isfile(avatarImageFilename): if os.path.isfile(avatarImageFilename):
return '/avatars/'+actorStr+'.png' return '/avatars/'+actorStr+'.png'
avatarImageFilename=baseDir+'/cache/avatars/'+actorStr+'.jpg' avatarImageFilename=avatarImagePath+'.jpg'
if os.path.isfile(avatarImageFilename): if os.path.isfile(avatarImageFilename):
return '/avatars/'+actorStr+'.jpg' return '/avatars/'+actorStr+'.jpg'
avatarImageFilename=baseDir+'/cache/avatars/'+actorStr+'.gif' avatarImageFilename=avatarImagePath+'.gif'
if os.path.isfile(avatarImageFilename): if os.path.isfile(avatarImageFilename):
return '/avatars/'+actorStr+'.gif' return '/avatars/'+actorStr+'.gif'
if os.path.isfile(avatarImagePath):
return '/avatars/'+actorStr
if personJson.get('icon'): if personJson.get('icon'):
if personJson['icon'].get('url'): if personJson['icon'].get('url'):