Markdown.XAML icon indicating copy to clipboard operation
Markdown.XAML copied to clipboard

Support Embedded Images

Open Axemasta opened this issue 5 years ago • 0 comments

I noticed that the way you're doign images is to copy them to the output directory and load from the file system. I wouldn't want to do this with my applications (I want an exe and nothing else).

I've modified my own copy to load these resources.

All that needs changing is the ImageInlineEvaluator method where it loads the BitmapImage:

imgSource = new BitmapImage();
imgSource.BeginInit();
imgSource.CacheOption = BitmapCacheOption.None;
imgSource.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
imgSource.CacheOption = BitmapCacheOption.OnLoad;
imgSource.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
//imgSource.UriSource = new Uri(url);
//imgSource.UriSource = new Uri(@"pack://application:,,,/Assets/yourimage.png", UriKind.RelativeOrAbsolute);
imgSource.UriSource = new Uri($"pack://application:,,,{url}", UriKind.RelativeOrAbsolute);
imgSource.EndInit();

If I find time I'll think of a nice way to switch between pulling the file from the filesystem or looking for embedded images. This currently requires the following markdown syntax: ![My Image](/Assets/myimage.png)

Axemasta avatar Dec 19 '19 14:12 Axemasta