Skip to content

Commit a60f3ea

Browse files
committed
If an alt attribute has been added to the image tag helper then we can just output that value
1 parent 7b2a60a commit a60f3ea

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Our.Umbraco.TagHelpers/ImgTagHelper.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
185185
{
186186
output.Attributes.Add("alt", GetImageAltText(MediaItem));
187187
}
188-
#endregion
188+
#endregion
189+
#region Use the alt text the user specified
190+
else
191+
{
192+
output.Attributes.Add("alt", ImgAlt);
193+
}
189194
#endregion
190195
}
191196
else if (!string.IsNullOrEmpty(FileSource))
@@ -201,10 +206,16 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
201206
{
202207
output.Attributes.Add("alt", GetImageAltText(FileSource));
203208
}
204-
#endregion
205-
206-
#region If width & height are not defined then return a basic <img> with just a src, alt & class (if provided)
207-
if (ImgWidth == 0 || ImgHeight == 0)
209+
#endregion
210+
#region Use the alt text the user specified
211+
else
212+
{
213+
output.Attributes.Add("alt", ImgAlt);
214+
}
215+
#endregion
216+
217+
#region If width & height are not defined then return a basic <img> with just a src, alt & class (if provided)
218+
if (ImgWidth == 0 || ImgHeight == 0)
208219
{
209220
output.Attributes.Add("src", FileSource);
210221

0 commit comments

Comments
 (0)