AppImageTagHelper Class
Definition
- Namespace
- Cuemon.AspNetCore.Razor.TagHelpers
- Assemblies
- 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)
{
Src = "images/logo.svg",
Alt = "Codebelt logo"
};
Console.WriteLine(FormatAssetUrl(tagHelper.Options, tagHelper.Src));
}
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
| Name | Description |
|---|---|
| AppImageTagHelper(IOptions<AppTagHelperOptions>, ICacheBusting) | Initializes a new instance of the AppImageTagHelper class. |
See Also
ImageTagHelper<TOptions>