Table of Contents

Class ContentItemAssetImageTagHelper

Namespace
Kentico.Content.Web.Mvc
Assembly
Kentico.Content.Web.Mvc.dll

Tag helper to render img' tag for the content item image asset. The tag is activated by the 'kxp-img' attribute that accepts ContentItemAsset object. The tag helper will prefill the 'src' attribute with the URL of the image asset. If 'kxp-img-dimensions' tag is set to true (or just included without any value), the tag helper will also prefill the 'width' and 'height' attributes of the image. Optionally, the 'kxp-img-variant' attribute can be used to specify the variant name. In case it's present, the 'src' will be pointing to the variant url and 'width' and 'height' will be based on variant.

[HtmlTargetElement("img", Attributes = "kxp-img")]
public class ContentItemAssetImageTagHelper : TagHelper
Inheritance
object
TagHelper
ContentItemAssetImageTagHelper
Extension Methods

Constructors

ContentItemAssetImageTagHelper()

public ContentItemAssetImageTagHelper()

Properties

Asset

Gets or sets the content item image asset.

[HtmlAttributeName("kxp-img")]
public ContentItemAsset Asset { get; set; }

Property Value

ContentItemAsset

IncludeDimensions

Indicates whether to render 'width' and 'height' attributes for the image.

[HtmlAttributeName("kxp-img-dimensions")]
public bool IncludeDimensions { get; set; }

Property Value

bool

VariantName

If provided, will adjust the 'src' attribute to point to the variant URL.

[HtmlAttributeName("kxp-img-variant")]
public string VariantName { get; set; }

Property Value

string

Methods

Process(TagHelperContext, TagHelperOutput)

public override void Process(TagHelperContext context, TagHelperOutput output)

Parameters

context TagHelperContext
output TagHelperOutput