-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
Picture + webp #649
Picture + webp #649
Conversation
✅ Deploy Preview for hugo-congo ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
I agree that adoption on this is getting better all the time and so it would be great to be able to use webp images, although I do wonder if we still need to have a fallback in case it's not supported by the browser? Should this be something that's a configuration flag in the theme? |
My personal preference is to keep fallback. Regarding configuration: Also I implemented it only for render hook, but we have other images. I wonder if I can refactor it in shortcode and reuse everywhere |
4108c35
to
759982f
Compare
|
2c9bbf2
to
7d562c7
Compare
7d562c7
to
9b64aa8
Compare
I can refactor code to use https://github.com/stereobooster/hugo-ideal-image if you want |
@@ -24,7 +25,7 @@ | |||
{{ with $resource }} | |||
<figure> | |||
<picture> | |||
{{ if ne .MediaType.SubType "svg" }} | |||
{{ if (and (ne .MediaType.SubType "svg") $webp) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this break svg support?
I'm probably wrong, but in my mind, This evaluation is
if ( (not svg) AND $webp (which is a param bool) )
which I THINK would undesirably evaluate false in the case of:
is_svg? -> true
webp = false
I could be wrong tho.... I'm wrong a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will evaluate to false. But this branch is not meant for SVG. SVG is displayed in other branches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I wrote this code I come with more advanced and cleaner solution:
- https://github.com/stereobooster/hugo-ideal-image/blob/main/layouts/partials/picture.html
- https://github.com/stereobooster/hugo-ideal-image/blob/main/layouts/_default/_markup/render-image.html
I asked author if they want it to be integrated
I'm not particularly interested in including external modules into the base theme. |
It's not a module, just an example implementation. I will inline all the code (which is picture.html) and then reuse it everywhere |
closed in favour of #693 |
webp
should be smaller in size than any other format. Except AVIF. Requires #645 PR firstSupport is good:
Related to #644