Skip to content

Commit 0f4c945

Browse files
Improved height calculation when using src
1 parent 32b2dac commit 0f4c945

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Our.Umbraco.TagHelpers/ImgTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
215215
width = ImgWidth;
216216
height = ImgHeight;
217217

218-
imgSrc = AddQueryToUrl(FileSource, "width", width.ToString());
218+
imgSrc = AddQueryToUrl(FileSource, "width", width.ToString()) + "&height=" + height.ToString();
219219

220220
#region Autogenerate alt text if unspecfied
221221
if (string.IsNullOrWhiteSpace(ImgAlt))
@@ -384,7 +384,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
384384
if (!string.IsNullOrEmpty(FileSource) && ImgWidth > 0 && ImgHeight > 0)
385385
{
386386
sourceHeight = size.ImageHeight > 0 ? size.ImageHeight : (ImgHeight / ImgWidth) * size.ImageWidth;
387-
var sourceUrl = AddQueryToUrl(FileSource, "width", size.ImageWidth.ToString());
387+
var sourceUrl = AddQueryToUrl(FileSource, "width", size.ImageWidth.ToString()) + "&height=" + size.ImageHeight;
388388
sb.AppendLine($"<source {(jsLazyLoad ? "data-" : "")}srcset=\"{sourceUrl}\" media=\"({(_globalSettings.OurImg.MobileFirst ? $"min-width: {minWidth}" : $"max-width: {minWidth - 1}")}px)\" width=\"{size.ImageWidth}\"{(sourceHeight > 0 ? $" height=\"{sourceHeight}\"" : "")} />");
389389

390390
}

0 commit comments

Comments
 (0)