gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local Images not loading?

krissbennett opened this issue · comments

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

  • I can reproduce this issue with a vanilla SwiftUI project.
  • I can reproduce this issue using the main branch of this package.
  • This bug hasn't been addressed in an existing GitHub issue.

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
    """,
    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

  • MarkdownUI: 2.2.0
  • OS: iOS 16
  • Xcode: 15.0.1

Additional context
Nothing else to add.

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

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))