Class AppImageTagHelper
- Namespace
- Cuemon.AspNetCore.Razor.TagHelpers
- Assembly
- Cuemon.AspNetCore.Razor.TagHelpers.dll
Provides an implementation targeting <img> elements that supports ICacheBusting versioning of a static image placed on a location outside (but tied to) your application. This class cannot be inherited.
[HtmlTargetElement("app-img")]
public sealed class AppImageTagHelper : ImageTagHelper<AppTagHelperOptions>, ITagHelper, ITagHelperComponent, IConfigurable<AppTagHelperOptions>
- Inheritance
-
AppImageTagHelper
- Implements
- Inherited Members
Examples
The following example demonstrates how to create AppImageTagHelper with application-scoped options.
using System;
using Cuemon.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Options;
namespace MyApp.Examples;
public static class AppImageTagHelperExample
{
public static void Demonstrate()
{
var options = Options.Create(CreateOptions());
var tagHelper = new AppImageTagHelper(options);
Console.WriteLine(FormatAssetUrl(options.Value, "images/logo.svg"));
Console.WriteLine(tagHelper.GetType().Name);
}
private static AppTagHelperOptions CreateOptions() => new()
{
Scheme = ProtocolUriScheme.Relative,
BaseUrl = "static.cuemon.net"
};
private static string FormatAssetUrl(AppTagHelperOptions options, string asset)
{
return options.GetFormattedBaseUrl() + asset;
}
}
Constructors
AppImageTagHelper(IOptions<AppTagHelperOptions>, ICacheBusting)
Initializes a new instance of the AppImageTagHelper class.
public AppImageTagHelper(IOptions<AppTagHelperOptions> setup, ICacheBusting cacheBusting = null)
Parameters
setupIOptions<AppTagHelperOptions>The AppTagHelperOptions which need to be configured.
cacheBustingICacheBustingAn optional object implementing the ICacheBusting interface.
See Also
ImageTagHelper<TOptions>