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

Render svg images from markdown #43

Merged
merged 2 commits into from
May 25, 2024

Conversation

ThomasBoom89
Copy link
Contributor

Hi,
this PR will allow users to define an svg in Markdown:
![svg](./images/hugo-logo-wide.svg "Test for svg")

The current render-image.html tries to resize the given image. This is not possible for a svg and will raise an error:
execute of template failed at <$src.Resize>: error calling Resize: this method is only available for raster images.

So, I added a check for MediaSubType and will default to "normal" html img tag when svg is detected.
In the final rendered html view the svg will shrink to the size of the parent container if width is set on the svg and is wider than the parent.

@tomowang tomowang merged commit e049463 into tomowang:main May 25, 2024
@tomowang
Copy link
Owner

tomowang commented May 25, 2024

Thanks for the PR. Actually it has bug when checking resource type. See fix commit 6aeb747

@ThomasBoom89 ThomasBoom89 deleted the render-svg-images-from-markdown branch June 1, 2024 23:04
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