diff --git a/utils.js b/utils.js
index b5fa88a..b78ded9 100644
--- a/utils.js
+++ b/utils.js
@@ -150,9 +150,14 @@ export async function getMastodonPost(config) {
const link = item.querySelector('link')?.textContent.trim()
- // extract image from description html if available
- const imgMatch = description.match(/
]+src="([^"]+)"/)
- const image = imgMatch ? imgMatch[1] : null
+ // extract image from media:content or description html
+ // check for media:content (mastodon uses this for attachments)
+ const mediaContent = item.getElementsByTagName('media:content')[0]
+ let image = mediaContent?.getAttribute('url') || null
+ if (!image) {
+ const imgMatch = description.match(/
]+src="([^"]+)"/)
+ image = imgMatch ? imgMatch[1] : null
+ }
// use description as the text, stripping HTML
let cleanText = sanitizeHtml(description, {
@@ -171,9 +176,14 @@ export async function getMastodonPost(config) {
const description = firstItem.querySelector('description')?.textContent || ''
const link = firstItem.querySelector('link')?.textContent.trim()
- // extract image from description html if available
- const imgMatch = description.match(/
]+src="([^"]+)"/)
- const image = imgMatch ? imgMatch[1] : null
+ // extract image from media:content or description html
+ // check for media:content (mastodon uses this for attachments)
+ const mediaContent = firstItem.getElementsByTagName('media:content')[0]
+ let image = mediaContent?.getAttribute('url') || null
+ if (!image) {
+ const imgMatch = description.match(/
]+src="([^"]+)"/)
+ image = imgMatch ? imgMatch[1] : null
+ }
let cleanText = sanitizeHtml(description, {
allowedTags: [],