Skip to content

Commit

Permalink
fix: get tweet image when it's a tweet (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats authored Jan 27, 2023
1 parent 7748d97 commit f3540a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/metascraper-twitter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ module.exports = () => {
})
],
image: [
toImage($ => avatarUrl($jsonld('author.image.contentUrl')($))),
toImage(
($, url) =>
isTweet(url) && $('meta[property="og:image"]').attr('content')
),
toImage(($, url) => isTweet(url) && $('video').attr('poster')),
toImage($ => avatarUrl($jsonld('author.image.contentUrl')($))),
toImage($ => avatarUrl($('article img[src]').attr('src')))
],
video: [toVideo(($, url) => isTweet(url) && $('video').attr('src'))],
Expand Down
4 changes: 2 additions & 2 deletions packages/metascraper-twitter/test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Generated by [AVA](https://avajs.dev).
author: '#!/kiko/beats',
date: '2017-06-28T19:01:34.000Z',
description: '“Experimenting with Clearbit API + Apple TV 3D Parallax https://t.co/Qsm163k4mJ”',
image: 'https://pbs.twimg.com/tweet_video_thumb/DDbh3WCXYAAZfz9.jpg',
image: 'https://pbs.twimg.com/tweet_video_thumb/DDbh3WCXYAAZfz9.jpg:large',
lang: 'en',
publisher: 'Twitter',
title: '@Kikobeats on Twitter',
Expand All @@ -83,7 +83,7 @@ Generated by [AVA](https://avajs.dev).
author: 'Brad, what are you gonna do?',
date: '2017-11-25T18:04:12.000Z',
description: '“Lo mejor de @codemotion_es #codemotionMadrid es estar con la gente que quieres 😍@ladyCircus”',
image: 'https://pbs.twimg.com/profile_images/1603675274348040192/y9P6VlyX_400x400.jpg',
image: 'https://pbs.twimg.com/media/DPfzNMGXUAESoL3.jpg:large',
lang: 'en',
publisher: 'Twitter',
title: '@k4rliky on Twitter',
Expand Down
Binary file modified packages/metascraper-twitter/test/snapshots/index.js.snap
Binary file not shown.

0 comments on commit f3540a6

Please sign in to comment.