Skip to content

Commit b0fa53c

Browse files
author
Warren Buckley
committed
Merge branch 'img-helper-alt-fix' of https://github.com/richarth/Our-Umbraco-TagHelpers into richarth-img-helper-alt-fix
2 parents a066876 + c88aee3 commit b0fa53c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Our.Umbraco.TagHelpers/ImgTagHelper.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
180180
height = (originalHeight / originalWidth) * width;
181181
}
182182

183-
#region Autogenerate alt text
183+
#region Autogenerate alt text if unspecfied
184184
if (string.IsNullOrWhiteSpace(ImgAlt))
185185
{
186186
output.Attributes.Add("alt", GetImageAltText(MediaItem));
187187
}
188-
#endregion
188+
else
189+
{
190+
output.Attributes.Add("alt", ImgAlt);
191+
}
189192
#endregion
190193
}
191194
else if (!string.IsNullOrEmpty(FileSource))
@@ -196,11 +199,15 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
196199

197200
imgSrc = AddQueryToUrl(FileSource, "width", width.ToString());
198201

199-
#region Autogenerate alt text
202+
#region Autogenerate alt text if unspecfied
200203
if (string.IsNullOrWhiteSpace(ImgAlt))
201204
{
202205
output.Attributes.Add("alt", GetImageAltText(FileSource));
203206
}
207+
else
208+
{
209+
output.Attributes.Add("alt", ImgAlt);
210+
}
204211
#endregion
205212

206213
#region If width & height are not defined then return a basic <img> with just a src, alt & class (if provided)

0 commit comments

Comments
 (0)