Search Results for

    Show / Hide Table of Contents
    View Source

    Class HtmlImageSourceParser

    Utility class used to parse and update image sources in HTML content based on Umbraco media references.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Templates
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class HtmlImageSourceParser

    Constructors

    View Source

    HtmlImageSourceParser(Func<Guid, string>)

    Initializes a new instance of the HtmlImageSourceParser class.

    Declaration
    public HtmlImageSourceParser(Func<Guid, string> getMediaUrl)
    Parameters
    Type Name Description
    Func<Guid, string> getMediaUrl

    A function that retrieves the media URL for a given GUID.

    View Source

    HtmlImageSourceParser(IPublishedUrlProvider)

    Initializes a new instance of the HtmlImageSourceParser class.

    Declaration
    public HtmlImageSourceParser(IPublishedUrlProvider publishedUrlProvider)
    Parameters
    Type Name Description
    IPublishedUrlProvider publishedUrlProvider

    The published URL provider for resolving media URLs.

    Methods

    View Source

    EnsureImageSources(string)

    Parses the string looking for Umbraco image tags and updates them to their up-to-date image sources.

    Declaration
    public string EnsureImageSources(string text)
    Parameters
    Type Name Description
    string text
    Returns
    Type Description
    string
    Remarks

    Umbraco image tags are identified by their data-udi attributes

    View Source

    FindUdisFromDataAttributes(string)

    Parses out media UDIs from an html string based on 'data-udi' html attributes

    Declaration
    public IEnumerable<Udi> FindUdisFromDataAttributes(string text)
    Parameters
    Type Name Description
    string text
    Returns
    Type Description
    IEnumerable<Udi>
    View Source

    RemoveImageSources(string)

    Removes media URLs from <img> tags where a data-udi attribute is present

    Declaration
    public string RemoveImageSources(string text)
    Parameters
    Type Name Description
    string text
    Returns
    Type Description
    string
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX