From 7b1da2f1a7eacfeb2a7ef8455a5e14f23dbafc18 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 13 Jun 2022 23:59:56 +0200 Subject: [PATCH] fixed image base path not being applied properly --- MLEM.Ui/Parsers/UiMarkdownParser.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MLEM.Ui/Parsers/UiMarkdownParser.cs b/MLEM.Ui/Parsers/UiMarkdownParser.cs index 612c85d..e2ebcd8 100644 --- a/MLEM.Ui/Parsers/UiMarkdownParser.cs +++ b/MLEM.Ui/Parsers/UiMarkdownParser.cs @@ -32,7 +32,6 @@ namespace MLEM.Ui.Parsers { /// /// The base path for markdown images, which is prepended to the image link. - /// Note that this is only applied for local images (ones whose link doesn't start with http). /// public string ImageBasePath; /// @@ -163,6 +162,9 @@ namespace MLEM.Ui.Parsers { async void LoadImageAsync() { var loc = imageMatch.Groups[1].Value; + // only apply the base path for relative files + if (this.ImageBasePath != null && !loc.StartsWith("http") && !Path.IsPathRooted(loc)) + loc = $"{this.ImageBasePath}/{loc}"; try { Texture2D tex; if (loc.StartsWith("http")) { @@ -171,8 +173,6 @@ namespace MLEM.Ui.Parsers { tex = Texture2D.FromStream(this.GraphicsDevice, src); } } else { - if (this.ImageBasePath != null) - loc = $"{this.ImageBasePath}/{loc}"; using (var stream = Path.IsPathRooted(loc) ? File.OpenRead(loc) : TitleContainer.OpenStream(loc)) tex = Texture2D.FromStream(this.GraphicsDevice, stream); }