diff --git a/Our.Umbraco.TagHelpers/ImgTagHelper.cs b/Our.Umbraco.TagHelpers/ImgTagHelper.cs index 60ca69c..5f287cc 100644 --- a/Our.Umbraco.TagHelpers/ImgTagHelper.cs +++ b/Our.Umbraco.TagHelpers/ImgTagHelper.cs @@ -180,12 +180,17 @@ public override void Process(TagHelperContext context, TagHelperOutput output) height = (originalHeight / originalWidth) * width; } - #region Autogenerate alt text + #region Autogenerate alt text if unspecfied if (string.IsNullOrWhiteSpace(ImgAlt)) { output.Attributes.Add("alt", GetImageAltText(MediaItem)); } + else + { + output.Attributes.Add("alt", ImgAlt); + } #endregion + #endregion } else if (!string.IsNullOrEmpty(FileSource)) @@ -196,11 +201,15 @@ public override void Process(TagHelperContext context, TagHelperOutput output) imgSrc = AddQueryToUrl(FileSource, "width", width.ToString()); - #region Autogenerate alt text + #region Autogenerate alt text if unspecfied if (string.IsNullOrWhiteSpace(ImgAlt)) { output.Attributes.Add("alt", GetImageAltText(FileSource)); } + else + { + output.Attributes.Add("alt", ImgAlt); + } #endregion #region If width & height are not defined then return a basic with just a src, alt & class (if provided)