My friend the brilliant Terence Eden has been working out how to fix the problem of decaying Twitter embeds – more and more people are finally leaving the Musk propaganda machine that X has become1, and specifically, because he is against <iframe>
s, which, I can understand. He’s published a script on GitHub that will allow you to convert Tweet IDs into semantic HTML with a screenshot fallback, which are better embed options at this point. Added bonus is that it also removes the tracking back to X.
OK gang! This is ready for you to test.
python tweet2html.py –css 1234
That will take a Twitter ID and return HTML and CSS for you to embed in your website with no calling back to Twitter.
Features:
Avatars inlined as Base64 WebP
All attached photos inlined
Video poster inline, <video> to original source
Hyperlinks don't use t.co
#⃣ Hashtags and @ mentions linkedSemantic time
and
counts
Try it out at https://github.com/edent/Tweet2Embed
Feedback and pull requests very welcome!
I deleted all of my accounts on that platform last year, and it has left a number of holes in my WordPress blog where I’d embedded content from over there.
Unfortunately, this has had two other results:
- I cannot use the result from Tweet2Embed to replace my old embeds, because they are no longer there for the script to go and rehydrate into those nice semantic HTML versions.
- my old account name has been taken by someone else, and that is not one of the other very fine Andy Pipers that I know, but a bit of a strange individual AFAICT. This was always a risk of completely deleting the account and not maintaining the existence of the username, but I really wanted to be completely off that platform, for Reasons.
When I deleted my accounts I knew that these were going to be issues but I simply ignored the embed issue2. As and when I can, I’m now going through older posts to look for those embeds (I think the “best” ? way seems to be searching for “[tweet” in the WordPress editor to look for posts that include the old shortcode). I do have my content archived and re-hosted on a GitHub Pages site, so I can at least drop the Tweet IDs in to that, and get the text of the original post. I’m going to manually screenshot and update the back posts as best I can.
Working on it! (apologies for any weirdly-delayed pingbacks as I update old posts…)
I noted that Terence also plans to make something similar for Mastodon embeds to avoid the default <iframe>
option – I’m using Stefan Bohacek’s Fediverse Embeds plugin for WordPress to improve them on this blog already. YMMV!
- If you’re on X, the fact that Musk is apparently posting direct attacks on the UK government and false information about recent events here, is yet another reason for you to leave it. Get out and start fresh somewhere better. I recommend Mastodon; Threads and Bluesky are alternatives you can also get value from; I’m on all three.
︎
- Another embed decay issue is that the new owners have gutted the old content of things like the TwitterDev YouTube channel, so my videos from there are now no longer visible; I did manage to save a couple of those for myself to re-host, and I’m also going to try to re-embed those in older posts here. I have a personal policy now to always require a copy of videos of my talks, so that I can have them for the future in case an event chooses to delete older content.
︎