MarkdownView icon indicating copy to clipboard operation
MarkdownView copied to clipboard

Can't load Image on MarkdownView

Open lucascorrea opened this issue 6 years ago • 3 comments

Hey Guys,

I have a problem with load image. In the screenshot, we can see that the MarkdownView does not load the image, but the image exists on the folder.

Has anyone had the same problem as me? Could someone help me solve this bug, please?

screenshot 2018-10-16 at 12 56 022

lucascorrea avatar Oct 16 '18 12:10 lucascorrea

I encountered exactly the same problem, have you found a solution?

fujianjin6471 avatar Oct 28 '18 14:10 fujianjin6471

I encountered exactly the same problem, have you found a solution?

It's very stranger. In Simulator, it works but on the device not.

lucascorrea avatar Nov 05 '18 13:11 lucascorrea

A bit late to the party, but I think the issue is WKWebView doesn't have access to your AppData Documents folder by default.

For anyone coming here, it's worth connecting to WKWebView using Safari's web inspector and checking for any error messages on Network or Console.

brunnobraga avatar Jan 24 '20 12:01 brunnobraga

Did anyone find a solution for displaying local images?

manuelzi avatar Aug 25 '23 14:08 manuelzi

Hey Manuelzi, I didn't remember how I fixed it, but you can see it on the file.

https://github.com/securityfirst/Umbrella_ios/blob/master/Umbrella/ViewControllers/Lesson/MarkdownViewController.swift

lucascorrea avatar Aug 25 '23 17:08 lucascorrea

Hey Manuelzi, I didn't remember how I fixed it, but you can see it on the file.

https://github.com/securityfirst/Umbrella_ios/blob/master/Umbrella/ViewControllers/Lesson/MarkdownViewController.swift

Thank you, will check it out!

manuelzi avatar Aug 25 '23 17:08 manuelzi

@lucascorrea Got it working with MarkdownView. Just had to remove "file://" from the URL encoded string. Thanks again!

let imageElement: String = Bundle.main.path(forResource: "<FILENAME>", ofType: "png").map {
    let imageUrl = URL(fileURLWithPath: $0).absoluteString.replacingOccurrences(of: "file://", with: "")
    return "![](\(imageUrl))"
} ?? ""

manuelzi avatar Aug 26 '23 10:08 manuelzi