-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
imageConfig with SVG images #3700
Comments
Do you have any references saying that this is relevant for SVG? |
What do you mean by "relevant"? Width and height apply to SVG too. Maybe this helps? https://css-tricks.com/scale-svg/#article-header-id-2 |
FWIW, you can do this in a pretty clever way using |
That is for inlined SVG :) I'm talking about using SVG with an |
Right. 1 less HTTP request. Even better. |
Here's not the place or the time to discuss the pros and cons of inlining stuff. Hint: http/2. |
I mean:
So by relevant I mean this: Am I right or wrong in the last bullet point above? |
SVG elements can and do declare intrinsic widths and heights. I make images like this in a text editor. |
I think with your "hint," you just did. |
Please stop polluting the issue with useless comments. |
@XhmikosR I'm curious as to the use case where these values would be returned. Icon list? Image library? |
|
Yup, exactly this. Since HTML is the first thing being parsed, if each
image has width and height attributes you avoid useless reflows.
My use case is a gallery with variable dimensions so I definitely need this
feature. Currently I have to specify the dimensions in a data file which
isn't as automatic as it could be.
…On Jul 15, 2017 19:13, "adiabatic" ***@***.***> wrote:
I'm curious as to the use case where these values would be returned.
height and width attributes in image tags so the browser doesn't have to
start downloading the images to know how space they'll take up. It's a
page-layout-speed optimization.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3700 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAVVtTjFdNZ4WhChv7GtE8ez1nYpYZOnks5sOOU4gaJpZM4OYS7W>
.
|
Ah, I see. Thanks you to you both. I knew about other formats being affected (i.e., jpg and png), but I had no idea this affected SVG since it's just XML at the end of the day. Seems I am always learning something new about SVGs 😄 I had red the Bellamy-Royds article above and have always followed its advice to avoid these attributes altogether. |
So, any news about this, guys? |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
I'd still like to see this added, if it's not a lot of work. |
This became even more relevant with the recent introduction of browser support for the HTML-native lazy When we use Markdown Render Hooks to add the execute of template failed: template: _default/_markup/render-image.html:4:146: executing "_default/_markup/render-image.html" at <imageConfig (add "static/" .Destination)>: error calling imageConfig: image: unknown format Since Go template code is always entirely evaluated regardless of conditional statements, I don't know of any easy workaround to still support SVG images. I think SVG is the only image format supported by the HTML |
I also wouldn't mind seeing this for the exact reasons mentioned, lazyloading SVG and minimizing reflow. Is there some other function like |
@jcackowski
Then I created another partial as
I can use it in a shortcode like this:
Please note that this relies on images stored in the assets folder. Plus it only uses the viewBox of the SVG, not the actual width and height. |
See unresolved Hugo issue: gohugoio/hugo#3700 Workaround is to manually define SVG size: site.Params.header.image.width site.Params.header.image.height
Part 2/2. See unresolved Hugo issue: gohugoio/hugo#3700 Workaround is to manually define SVG size: site.Params.header.image.width site.Params.header.image.height
See unresolved Hugo issue: gohugoio/hugo#3700 Workaround is to manually define SVG size: site.Params.header.image.width site.Params.header.image.height
Part 2/2. See unresolved Hugo issue: gohugoio/hugo#3700 Workaround is to manually define SVG size: site.Params.header.image.width site.Params.header.image.height
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi.
I'd like to ask if it's possible to add support for SVG images in
imageConfig
. I know SVG are vectors but there are cases SVGs still use width and height along with viewBox. Not sure if Go allows this or not, just thinking out loud.Thanks!
The text was updated successfully, but these errors were encountered: