Embed Mastodon post/toot

Use case or problem

Twitter is failing and is a very sad place, even sadder than it was a year or two ago. A lot of the most interesting discussions are happening on Mastodon now, and other places in the Fediverse.

Obsidian already has a very useful embed function for YouTube video and Tweets. Can there be an embed for a Mastadon post?

This would be a start for support for the Fediverse, and as the ActivityPub protocol develops and is adopted by more organizations and platforms, embedded an ActivityPub action would be even more useful.

Proposed solution

Similar to embedding a Tweet.
![](https://mas.to/@obsidian/111495540391606053)

Current workaround (optional)

Currently I use a normal link to a [post](https://mas.to/@obsidian/111495540391606053).

But Mastodon already offers an iframe embed code for all posts. It would be nice to have this done automatically, as a first class embed.

<iframe src="https://mas.to/@obsidian/111495540391606053/embed" width="400" allowfullscreen="allowfullscreen" sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-forms"></iframe>

Related feature requests (optional)

4 Likes

Pitching in my support for Mastodon toot embeds, just the way they work with Twitter. :+1:

Yup, there’s that Mastodon embed code that does work, but that requires a bit more manual work, and you need to delete part of the embed code Mastodon feeds to you (or so it seems; my Mastodon server inserts it automatically); the following part seems excessive:

<script src="https://assets.infosec.exchange/embed.js" async="async"></script>

Looks like you only need the first part of the embed code for Obsidian embeds:

<iframe src="https://infosec.exchange/@aleave/111730570909794213/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="800" allowfullscreen="allowfullscreen"></iframe>

By the way, @majdal, do you know of a way to control the height of an embedded toot? I can swap the default width parameter from the default 400 to 800, which is the width I prefer, but it appears impossible to make the toots appear in full height here? :thinking: Or at least to be taller than they currently are? I tried inserting the height parameter in the embed code and experimenting with it, but toot embeds still remain in default height for me in Obsidian, which I find insufficient for a nice display of embedded toots. This height control may be/likely is a Mastodon rather than an Obsidian thing, of course.

1 Like

Hmmm – not sure about the height. It seems like the height is implicitly set height="auto". Changing it to a specific number, e.g. height="500" worked. I use the minimal theme, so that might be it?

I’m curious as to what is causing the auto to be calculated incorrectly though.

It just doesn’t work for me at all.

No matter if I insert height="auto", height="500" or height="1000", the result in Obsidian is always the same: a very short window, I’d say 200 pixels in height at most.

In the example post I gave above, Obsidian only displays the first 3 lines of the post, and you need to scroll manually in order to read the rest of the post. On Mastodon’s site, the post is 7 lines long.

I use Obsidian’s default theme. And I particularly care about the Mastodon posts being displayed neatly on my Obsidian Publish site. Because they’re not being displayed neatly, I prefer embedding exTwitter posts for now. Sigh.

1 Like

Strange. What theme do you use? I use minimal, and it setting height works correctly.

As I said, I use Obsidian’s default theme, and it just doesn’t work. :person_shrugging: (I would especially need for it to work on my Obsidian Publish site.)