Search Results for

    Show / Hide Table of Contents
    View Source

    Class OEmbedProviderBase

    Abstract base class for OEmbed providers that implements the IEmbedProvider interface.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Media.EmbedProviders
    Assembly: Umbraco.Core.dll
    Syntax
    public abstract class OEmbedProviderBase : IEmbedProvider

    Constructors

    View Source

    OEmbedProviderBase(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 Source

    ApiEndpoint

    The OEmbed API Endpoint

    Declaration
    public abstract string ApiEndpoint { get; }
    Property Value
    Type Description
    string
    View Source

    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 Source

    UrlSchemeRegex

    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 Source

    DownloadResponseAsync(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.

    View Source

    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.

    View Source

    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 null for no constraint.

    int? maxHeight

    The maximum height, or null for no constraint.

    Returns
    Type Description
    string

    The full OEmbed provider URL with query parameters.

    View Source

    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 null for no constraint.

    int? maxHeight

    The maximum height, or null for no constraint.

    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 null.

    View Source

    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 null.

    Type Parameters
    Name Description
    T

    The type to deserialize the response to.

    View Source

    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 null for no constraint.

    int? maxHeight

    The maximum height of the embedded content, or null for no constraint.

    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 null if unavailable.

    View Source

    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 null for no constraint.

    int? maxHeight

    The maximum height, or null for no constraint.

    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 null.

    View Source

    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.

    View Source

    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.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX