gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.44k stars 298 forks source link

Local Images not loading? #280

Closed krissbennett closed 9 months ago

krissbennett commented 9 months ago

Thank you for contributing to MarkdownUI!

Before you submit an issue, please complete the report with all the relevant details for your bug and go through every item in the checklist.

Describe the bug I have followed what I believe is the right guidance on loading local images within the Markdown, if I pass an invalid URL for the image I see an error in the console, but even when passing the correct URL, I don't see any errors and image doesn't load.

Checklist

Steps to reproduce Explanation of how to reproduce the incorrect behavior. This could include an attached project, a link to code, or a Markdown-formatted text exhibiting the issue.

  1. Simple SwiftUI view

  2. testImage.jpg is in the app bundle

  3. add to view Markdown( """

    Title

            ![Image](testImage.jpeg)
            """,
            baseURL: Bundle.main.resourceURL
    )
    .markdownImageProvider(.asset)
  4. Run in simulator

Expected behavior Expect to see image loaded from local file

Screenshots Image not loaded so nothing to show

Version information

Additional context Nothing else to add.

krissbennett commented 9 months ago

Also note that I have tried combination of baseURL and imageBaseURL with same effect. And with and without the markdownImageProvider

krissbennett commented 9 months ago

Resolved my problem by adding in a custom static var to my package to return its own bundle and then using:

.markdownImageProvider(AssetImageProvider(bundle: MyCustomPackage.bundle))