Add creator details to images, if available

main
Bob Mottram 2023-01-23 14:35:54 +00:00
parent d9143403fe
commit 6053d3b725
1 changed files with 19 additions and 0 deletions

View File

@ -1233,6 +1233,12 @@ def get_post_attachments_as_html(base_dir: str,
for attach in post_json_object['object']['attachment']: for attach in post_json_object['object']['attachment']:
if not (attach.get('mediaType') and attach.get('url')): if not (attach.get('mediaType') and attach.get('url')):
continue continue
media_license = ''
if attach.get('schema:license'):
media_license = attach['schema:license']
media_creator = ''
if attach.get('schema:creator'):
media_creator = attach['schema:creator']
media_type = attach['mediaType'] media_type = attach['mediaType']
image_description = '' image_description = ''
@ -1337,11 +1343,24 @@ def get_post_attachments_as_html(base_dir: str,
'<div id="' + post_id + '">\n' '<div id="' + post_id + '">\n'
attachment_str += '<a href="' + image_url + '" tabindex="10">' attachment_str += '<a href="' + image_url + '" tabindex="10">'
if media_license or media_creator:
attachment_str += '<figure>'
attachment_str += \ attachment_str += \
'<img loading="lazy" decoding="async" ' + \ '<img loading="lazy" decoding="async" ' + \
'src="' + image_url + \ 'src="' + image_url + \
'" alt="' + image_description + '" title="' + \ '" alt="' + image_description + '" title="' + \
image_description + '" class="attachment"></a>\n' image_description + '" class="attachment"></a>\n'
if media_license or media_creator:
attachment_str += '<figcaption>'
license_str = ''
if media_license:
license_str += '<a href="' + media_license + '">©</a>'
if media_creator:
if license_str:
license_str += ' '
license_str += media_creator
if media_license or media_creator:
attachment_str += license_str + '</figcaption></figure>'
if minimize_images: if minimize_images:
attachment_str += '</div></details>\n' attachment_str += '</div></details>\n'