Skip to content

Commit f9f3c90

Browse files
committed
handle x.com links as twitter embeds
1 parent 392e359 commit f9f3c90

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
3.9.5 (2024-12-13)
2+
-------------------------
3+
* Recognize x.com in URL to trigger tweet embeds
4+
15
3.9.4 (2024-12-04)
26
-------------------------
37
* Fix bug in WikipediaImage when float width parameters are sent to WP APIs

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@knight-lab/timelinejs",
3-
"version": "3.9.4",
3+
"version": "3.9.5",
44
"license": "MPL-2.0",
55
"description": "TimelineJS v3: A Storytelling Timeline built in JavaScript, made by Northwestern University Knight Lab.",
66
"dependencies": {

src/js/media/MediaType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function lookupMediaType(m, image_only) {
8989
{
9090
type: "twitter",
9191
name: "Twitter",
92-
match_str: "^(https?:)?\/*(www.)?twitter\.com",
92+
match_str: "^(https?:)?\/*(www.)?(twitter|x)\.com",
9393
cls: Twitter
9494
},
9595
{
@@ -247,4 +247,4 @@ export function lookupMediaType(m, image_only) {
247247
}
248248
}
249249
return false;
250-
}
250+
}

src/js/media/types/Twitter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Twitter extends Media {
1212
this._el.content_container.className = "tl-media-content-container tl-media-content-container-text";
1313

1414
// Get Media ID
15-
if (this.data.url.match("^(https?:)?\/*(www.)?twitter\.com")) {
15+
if (this.data.url.match("^(https?:)?\/*(www.)?(twitter|x)\.com")) {
1616
if (this.data.url.match("status\/")) {
1717
this.media_id = this.data.url.split("status\/")[1];
1818
} else if (this.data.url.match("statuses\/")) {
@@ -70,8 +70,8 @@ export default class Twitter extends Media {
7070
// Open links in new window
7171
tweet_text = tweet_text.replace(/<a href/ig, '<a target="_blank" rel="noopener" href');
7272

73-
if (tweet_text.includes("pic.twitter.com")) {
74-
73+
if (tweet_text.includes("pic.twitter.com") || tweet_text.includes("pic.x.com")) {
74+
// platform.x.com gets redirected to platform.twitter.com as of 2024-12-13
7575
loadJS('https://platform.twitter.com/widgets.js', function() {
7676
twttr.widgets.createTweet(self.media_id, self._el.content_item, {
7777
conversation: 'none', // or all
@@ -117,4 +117,4 @@ export default class Twitter extends Media {
117117
_updateMediaDisplay() {
118118

119119
}
120-
}
120+
}

0 commit comments

Comments
 (0)