Compensate when the image metadata isn't included in the event. Issue #24
This commit is contained in:
parent
c3e2241587
commit
97800146d8
1 changed files with 16 additions and 4 deletions
|
@ -62,16 +62,28 @@ def on_receive_events(transaction):
|
||||||
value = {"type": "photo", "version": "1.0"}
|
value = {"type": "photo", "version": "1.0"}
|
||||||
value["title"] = event['content']['body']
|
value["title"] = event['content']['body']
|
||||||
value["url"] = imgurl
|
value["url"] = imgurl
|
||||||
|
if 'w' in event['content']['info']:
|
||||||
value["width"] = event['content']['info']['w']
|
value["width"] = event['content']['info']['w']
|
||||||
|
else:
|
||||||
|
value["width"] = 200
|
||||||
|
if 'h' in event['content']['info']:
|
||||||
value["height"] = event['content']['info']['h']
|
value["height"] = event['content']['info']['h']
|
||||||
|
else:
|
||||||
|
value["height"] = 200
|
||||||
if 'thumbnail_info' in event['content']['info']:
|
if 'thumbnail_info' in event['content']['info']:
|
||||||
thmburl = app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:]
|
thmburl = app.config['MATRIX_HOST'] + '/_matrix/media/r0/download/' + event['content']['info']['thumbnail_url'][6:]
|
||||||
value["thumbnail_width"] = event['content']['info']['thumbnail_info']['w']
|
value["thumbnail_width"] = event['content']['info']['thumbnail_info']['w']
|
||||||
value["thumbnail_height"] = event['content']['info']['thumbnail_info']['h']
|
value["thumbnail_height"] = event['content']['info']['thumbnail_info']['h']
|
||||||
value["thumbnail_url"] = thmburl
|
value["thumbnail_url"] = thmburl
|
||||||
else:
|
else:
|
||||||
|
if 'w' in event['content']['info']:
|
||||||
value["thumbnail_width"] = event['content']['info']['w']
|
value["thumbnail_width"] = event['content']['info']['w']
|
||||||
|
else:
|
||||||
|
value["thumbnail_width"] = 200
|
||||||
|
if 'h' in event['content']['info']:
|
||||||
value["thumbnail_height"] = event['content']['info']['h']
|
value["thumbnail_height"] = event['content']['info']['h']
|
||||||
|
else:
|
||||||
|
value["thumbnail_height"] = 200
|
||||||
value["thumbnail_url"] = imgurl
|
value["thumbnail_url"] = imgurl
|
||||||
rawitem = {"type": "io.pnut.core.oembed", "value": value}
|
rawitem = {"type": "io.pnut.core.oembed", "value": value}
|
||||||
embed = [rawitem]
|
embed = [rawitem]
|
||||||
|
|
Loading…
Reference in a new issue