1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

fixed image base path not being applied properly

This commit is contained in:
Ell 2022-06-13 23:59:56 +02:00
parent f53305ce42
commit 7b1da2f1a7

View file

@ -32,7 +32,6 @@ namespace MLEM.Ui.Parsers {
/// <summary> /// <summary>
/// The base path for markdown images, which is prepended to the image link. /// 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).
/// </summary> /// </summary>
public string ImageBasePath; public string ImageBasePath;
/// <summary> /// <summary>
@ -163,6 +162,9 @@ namespace MLEM.Ui.Parsers {
async void LoadImageAsync() { async void LoadImageAsync() {
var loc = imageMatch.Groups[1].Value; 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 { try {
Texture2D tex; Texture2D tex;
if (loc.StartsWith("http")) { if (loc.StartsWith("http")) {
@ -171,8 +173,6 @@ namespace MLEM.Ui.Parsers {
tex = Texture2D.FromStream(this.GraphicsDevice, src); tex = Texture2D.FromStream(this.GraphicsDevice, src);
} }
} else { } else {
if (this.ImageBasePath != null)
loc = $"{this.ImageBasePath}/{loc}";
using (var stream = Path.IsPathRooted(loc) ? File.OpenRead(loc) : TitleContainer.OpenStream(loc)) using (var stream = Path.IsPathRooted(loc) ? File.OpenRead(loc) : TitleContainer.OpenStream(loc))
tex = Texture2D.FromStream(this.GraphicsDevice, stream); tex = Texture2D.FromStream(this.GraphicsDevice, stream);
} }