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

figure shortcode no longer supports SVG images #1620

Closed
thomwiggers opened this issue Mar 29, 2020 · 4 comments · Fixed by #1749
Closed

figure shortcode no longer supports SVG images #1620

thomwiggers opened this issue Mar 29, 2020 · 4 comments · Fixed by #1749
Labels

Comments

@thomwiggers
Copy link
Contributor

Describe the bug

A clear and concise description of what the bug is.

Using

{{< figure src="some.svg" >}}

now results in

Building sites … Total in 352 ms
Error: Error building site: "/home/thom/git/thomwiggers.nl/content/post/kems_in_tls_1.3/index.md:52:1": failed to render shortcode "figure": failed to process shortcode: "/home/thom/git/thomwiggers.nl/themes/academic/layouts/shortcodes/figure.html:6:22": execute of template failed: template: shortcodes/figure.html:6:22: executing "shortcodes/figure.html" at <$asset.Fit>: error calling Fit: *resources.genericResource is not an image

To Reproduce

Steps to reproduce the behavior:

Put an svg in your page

Expected behavior

SVG gets linked correctly

Technical details:

  • Academic Version: 8d25dbc
  • Hugo Version: v0.65.3-211BA42A/extended
@thomwiggers
Copy link
Contributor Author

Git bisect suggests 55228b7 is to blame.

@gcushen
Copy link
Collaborator

gcushen commented Mar 29, 2020

Note that Hugo does not currently support SVG as an image type but as a generic resource within the Hugo framework.

Academic's Figure code was not intended to work with SVG given Hugo does not yet support SVG as an image type, although in some versions of Academic it may have worked. Hence, this would be more of a question and feature request for adding SVG support to figures. Feel free to submit a PR.

An alternative approach for SVG might be to utilise the standard Markdown image syntax, with the caveat that it won't have the flexibility of figures.

@stale
Copy link

stale bot commented Apr 28, 2020

This issue has been automatically marked as stale because it has not had any recent activity. The resources of the Academic team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically close soon if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 28, 2020
@stale stale bot closed this as completed May 6, 2020
@beckerjohannes
Copy link
Contributor

beckerjohannes commented Jun 15, 2020

@gcushen could you reopen the issue and I'll provide a PR for this?

The current figure shortcode implementation tries to resize "image" resources and for others it just creates an <img> link.

The problem is, Hugo returns SVG for .Page.Resources.ByType "image", but does not support Fit. However, I fixed it for my site by additionally checking if .MediaType.SubType is equal to svg and skipping .Fit for those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants