From 8edd2ccd67e623e9b9e30688b9fdc3f7f182780b Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 19 Oct 2022 14:25:12 +0100 Subject: [PATCH] fix: quote image copyright text --- src/components/widgets/quote/Quote.jsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index a137ec4d..85f517dd 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -132,13 +132,11 @@ export default class Quote extends PureComponent { ) ).json(); - const license = - authorimglicensedata.query.pages[Object.keys(authorimglicensedata.query.pages)[0]] - .imageinfo[0].extmetadata.LicenseShortName; - const photographer = - authorimglicensedata.query.pages[Object.keys(authorimglicensedata.query.pages)[0]] - .imageinfo[0].extmetadata.Attribution || 'Unknown'; - authorimglicense = `© ${photographer.value}. ${license.value}`; + const metadata = authorimglicensedata.query.pages[Object.keys(authorimglicensedata.query.pages)[0]].imageinfo[0].extmetadata; + const license = metadata.LicenseShortName; + const photographer = metadata.Attribution.value || metadata.Artist?.value.match(/(?.+)<\/a>/i)?.groups.name || 'Unknown'; + authorimglicense = `© ${photographer}. ${license.value}`; + authorimglicense = authorimglicense.replace(/copyright\s/i, '').replace(/©\s©\s/, '© '); if (license.value === 'Public domain') { authorimglicense = null;