trying to add a new provider for embed on the rich text editor
Hi i am trying to add a new provider for embed on the rich text editor, every where ive looked online is saying add it to embeddedmedia.config but i dont seem to have this file! Im using v8 if anyone could shed some light that would be great. Also how do i use ifame in umbraco v8?
It's the same theory as in V7, except in V8 'a lot' of the configuration has moved from configuration files into code.
So for example if you wanted to create a new Embed provider for the DeviantArt website (like in the v7 documentation).. you'd create a provider like so:
using System.Collections.Generic;
using Umbraco.Web.Media.EmbedProviders;
namespace umbraco8.EmbedProviders
{
public class DeviantArtEmbedProvider : EmbedProviderBase
{
public override string ApiEndpoint => "https://backend.deviantart.com/oembed?url=";
public override string[] UrlSchemeRegex => new string[]
{
@"fav\.me/*"
};
public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();
public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
{
var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
return oembed.GetHtml();
}
}
}
This replaces what you would have added to the embeddedmedia.config file.
And then there is a further step to let Umbraco know about the provider, add a new class to your project inheriting 'IUserComposer' and we can use the OEmbedProviders extension method to add the new provider in eg:
using Umbraco.Core.Composing;
using Umbraco.Web;
using umbraco8.EmbedProviders;
namespace umbraco.Composing
{
public class RegisterEmbedProvidersComposer : IUserComposer
{
public void Compose(Composition composition) => composition.OEmbedProviders().Append<DeviantArtEmbedProvider>();
}
}
trying to add a new provider for embed on the rich text editor
Hi i am trying to add a new provider for embed on the rich text editor, every where ive looked online is saying add it to embeddedmedia.config but i dont seem to have this file! Im using v8 if anyone could shed some light that would be great. Also how do i use ifame in umbraco v8?
Thank you
Hi Jamie
It's the same theory as in V7, except in V8 'a lot' of the configuration has moved from configuration files into code.
So for example if you wanted to create a new Embed provider for the DeviantArt website (like in the v7 documentation).. you'd create a provider like so:
This replaces what you would have added to the embeddedmedia.config file.
And then there is a further step to let Umbraco know about the provider, add a new class to your project inheriting 'IUserComposer' and we can use the OEmbedProviders extension method to add the new provider in eg:
regards
Marc
I'm trying this but its not hitting RegisterEmbedProvidersComposer
is working on a reply...