Skip to content

Commit 520b139

Browse files
Alt tag attribute is added.
1 parent 7e16f08 commit 520b139

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/GravatarTagHelpers/GravatarImgTagHelper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public class GravatarImgTagHelper : TagHelper
5050
/// </summary>
5151
public bool UseSecureUrl { get; set; }
5252

53+
/// <summary>
54+
/// Alt tag for an image
55+
/// </summary>
56+
public string Alt { get; set; }
57+
5358
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
5459
{
5560
output.TagName = "img";
@@ -68,6 +73,9 @@ public override Task ProcessAsync(TagHelperContext context, TagHelperOutput outp
6873

6974
output.Attributes.Add("src", gravatarImageUrl);
7075

76+
if(!string.IsNullOrWhiteSpace(Alt))
77+
output.Attributes.Add("alt", Alt);
78+
7179
return base.ProcessAsync(context, output);
7280
}
7381
}

0 commit comments

Comments
 (0)