Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SVG previews in markdown #938

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

micahmo
Copy link
Member

@micahmo micahmo commented Dec 1, 2023

Pull Request Description

I was investigating issues I've seen displaying some images (most often in instance/community sidebars). It turns out that a common culprit is SVG files, which ExtendedImage cannot render.

This PR adds the ability to check whether an image is an SVG (getting only the headers, so the http request is lightweight), and if so, using a different widget to render the SVG (from jovial_svg) in markdown. This works in post bodies, comment bodies, and sidebars. It doesn't affect when a post link references an SVG. Like the web, that is still treated as an external link. It also doesn't allow SVGs to be tapped and opened in an image viewer.

I also enhanced the error messaging for when images legitimately don't load.

Note: I picked jovial_svg over the seemingly more popular flutter_svg because the latter failed to render the first thing I threw at it! 😊

Issue Being Fixed

Inability to render SVGs.

Screenshots / Recordings

Ignore the oversized Datadog image and render overflow. I would like to fix that separately!

Before

svg-before.mp4

After

svg-after.mp4

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@micahmo micahmo mentioned this pull request Dec 1, 2023
3 tasks
Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a couple of comments

lib/shared/common_markdown_body.dart Outdated Show resolved Hide resolved
lib/shared/common_markdown_body.dart Outdated Show resolved Hide resolved
@hjiangsu hjiangsu merged commit 8407e60 into thunder-app:develop Dec 4, 2023
1 check passed
@micahmo micahmo deleted the feature/support-svg branch December 4, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants