Skip to content

Commit c588003

Browse files
author
Warren Buckley
committed
Merge branch 'richarth-img-helper-alt-fix'
2 parents a066876 + 6024561 commit c588003

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Our.Umbraco.TagHelpers/ImgTagHelper.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,17 @@ 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+
else
189+
{
190+
output.Attributes.Add("alt", ImgAlt);
191+
}
188192
#endregion
193+
189194
#endregion
190195
}
191196
else if (!string.IsNullOrEmpty(FileSource))
@@ -196,11 +201,15 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
196201

197202
imgSrc = AddQueryToUrl(FileSource, "width", width.ToString());
198203

199-
#region Autogenerate alt text
204+
#region Autogenerate alt text if unspecfied
200205
if (string.IsNullOrWhiteSpace(ImgAlt))
201206
{
202207
output.Attributes.Add("alt", GetImageAltText(FileSource));
203208
}
209+
else
210+
{
211+
output.Attributes.Add("alt", ImgAlt);
212+
}
204213
#endregion
205214

206215
#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)