Class OEmbedProviderBase
Abstract base class for OEmbed providers that implements the IEmbedProvider interface.
Inheritance
Namespace: Umbraco.Cms.Core.Media.EmbedProviders
Assembly: Umbraco.Core.dll
Syntax
public abstract class OEmbedProviderBase : IEmbedProvider
Constructors
View SourceOEmbedProviderBase(IJsonSerializer)
Initializes a new instance of the OEmbedProviderBase class.
Declaration
protected OEmbedProviderBase(IJsonSerializer jsonSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IJsonSerializer | jsonSerializer | The JSON serializer. |
Properties
View SourceApiEndpoint
The OEmbed API Endpoint
Declaration
public abstract string ApiEndpoint { get; }
Property Value
| Type | Description |
|---|---|
| string |
RequestParams
A collection of querystring request parameters to append to the API URL
Declaration
public abstract Dictionary<string, string> RequestParams { get; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
Examples
?key=value&key2=value2
View SourceUrlSchemeRegex
A string array of Regex patterns to match against the pasted OEmbed URL
Declaration
public abstract string[] UrlSchemeRegex { get; }
Property Value
| Type | Description |
|---|---|
| string[] |
Methods
View SourceDownloadResponseAsync(string, CancellationToken)
Downloads the response content from the specified URL.
Declaration
public virtual Task<string> DownloadResponseAsync(string url, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download from. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation, containing the response content as a string. |
GetEmbedProviderUrl(string, int, int)
Gets the full OEmbed provider URL including the URL to embed and dimension constraints.
Declaration
public virtual string GetEmbedProviderUrl(string url, int maxWidth, int maxHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the media to embed. |
| int | maxWidth | The maximum width, or 0 for no constraint. |
| int | maxHeight | The maximum height, or 0 for no constraint. |
Returns
| Type | Description |
|---|---|
| string | The full OEmbed provider URL with query parameters. |
GetEmbedProviderUrl(string, int?, int?)
Gets the full OEmbed provider URL including the URL to embed and dimension constraints.
Declaration
public virtual string GetEmbedProviderUrl(string url, int? maxWidth, int? maxHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the media to embed. |
| int? | maxWidth | The maximum width, or |
| int? | maxHeight | The maximum height, or |
Returns
| Type | Description |
|---|---|
| string | The full OEmbed provider URL with query parameters. |
GetJsonBasedMarkupAsync(string, int?, int?, CancellationToken)
Gets the HTML markup for embedding media using a JSON-based OEmbed response.
Declaration
public virtual Task<string?> GetJsonBasedMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the media to embed. |
| int? | maxWidth | The maximum width, or |
| int? | maxHeight | The maximum height, or |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation, containing the HTML markup or |
GetJsonResponseAsync<T>(string, CancellationToken)
Gets the JSON response from the specified URL and deserializes it to the specified type.
Declaration
public virtual Task<T?> GetJsonResponseAsync<T>(string url, CancellationToken cancellationToken) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download from. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<T> | A task that represents the asynchronous operation, containing the deserialized response or |
Type Parameters
| Name | Description |
|---|---|
| T | The type to deserialize the response to. |
GetMarkupAsync(string, int?, int?, CancellationToken)
Gets the HTML markup for embedding the media content from the specified URL.
Declaration
public abstract Task<string?> GetMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the media to embed. |
| int? | maxWidth | The maximum width of the embedded content, or |
| int? | maxHeight | The maximum height of the embedded content, or |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation, containing the HTML markup or |
GetXmlBasedMarkupAsync(string, int?, int?, CancellationToken, string)
Gets the HTML markup for embedding media using an XML-based OEmbed response.
Declaration
public virtual Task<string?> GetXmlBasedMarkupAsync(string url, int? maxWidth, int? maxHeight, CancellationToken cancellationToken, string property = "/oembed/html")
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL of the media to embed. |
| int? | maxWidth | The maximum width, or |
| int? | maxHeight | The maximum height, or |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
| string | property | The XPath expression to select the HTML property. Defaults to "/oembed/html". |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous operation, containing the HTML markup or |
GetXmlProperty(XmlDocument, string)
Gets a property value from an XML document using an XPath expression.
Declaration
public virtual string GetXmlProperty(XmlDocument doc, string property)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlDocument | doc | The XML document. |
| string | property | The XPath expression to select the property. |
Returns
| Type | Description |
|---|---|
| string | The inner text of the selected node, or an empty string if not found. |
GetXmlResponseAsync(string, CancellationToken)
Gets the XML response from the specified URL.
Declaration
public virtual Task<XmlDocument> GetXmlResponseAsync(string url, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | url | The URL to download from. |
| CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete. |
Returns
| Type | Description |
|---|---|
| Task<XmlDocument> | A task that represents the asynchronous operation, containing the response as an System.Xml.XmlDocument. |