Change the code generated by embeding Tweets?

Is it possible to change the code that is generated when you embed a tweet in the TipTap RTE? Twitter has a dark mode version of embeds, and that version fits my site’s theme, but right now the writer has to manually edit the source code each time they embed a tweet.

Umbraco’s built-in oEmbed providers are not configurable[1], so you’ll need your own one that includes the parameter to enable dark mode in the oEmbed API request. It’s simpler than it sounds!

First create your own version of the X oEmbed provider:

public class DarkX : X
{
    public DarkX(IJsonSerializer jsonSerializer)
        : base(jsonSerializer)
    {
    }

    public override Dictionary<string, string> RequestParams 
        => new() { { "theme", "dark" } };
}

Then in a composer, replace the X provider with your own.

public class RegisterEmbedProvidersComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder) 
        => builder.EmbedProviders().Replace<X,DarkX>();
}

Full details on creating your own oEmbed providers are in the docs:


  1. There should totally be a PR for that! ↩︎