Skip to content

Commit de3145a

Browse files
committed
Fixes #1051
1 parent 238d287 commit de3145a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/MarkdownTextBlock/Display/XamlRenderer.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,29 @@ private void RenderImage(InlineCollection inlineCollection, ImageInline element,
905905
var image = new Image();
906906
var imageContainer = new InlineUIContainer() { Child = image };
907907

908+
// if url is not absolute we have to return as local images are not supported
909+
if (!element.Url.StartsWith("http") && !element.Url.StartsWith("ms-app"))
910+
{
911+
return;
912+
}
913+
908914
image.Source = new BitmapImage(new Uri(element.Url));
909915
image.HorizontalAlignment = HorizontalAlignment.Left;
910916
image.VerticalAlignment = VerticalAlignment.Top;
911917
image.Stretch = ImageStretch;
912918

913919
ToolTipService.SetToolTip(image, element.Tooltip);
914920

915-
// Add it to the current inlines
916-
inlineCollection.Add(imageContainer);
921+
// Try to add it to the current inlines
922+
// Could fail because some containers like Hyperlink cannot have inlined images
923+
try
924+
{
925+
inlineCollection.Add(imageContainer);
926+
}
927+
catch
928+
{
929+
// Ignore error
930+
}
917931
}
918932

919933
/// <summary>

0 commit comments

Comments
 (0)