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

Picture + webp #649

Closed
wants to merge 4 commits into from
Closed

Picture + webp #649

wants to merge 4 commits into from

Conversation

stereobooster
Copy link
Contributor

webp should be smaller in size than any other format. Except AVIF. Requires #645 PR first

Support is good:

Related to #644

@netlify
Copy link

netlify bot commented Sep 11, 2023

Deploy Preview for hugo-congo ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 74f82da
🔍 Latest deploy log https://app.netlify.com/sites/hugo-congo/deploys/651e881226da0700088de2a1
😎 Deploy Preview https://deploy-preview-649--hugo-congo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jpanther
Copy link
Owner

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?

@stereobooster
Copy link
Contributor Author

stereobooster commented Sep 12, 2023

My personal preference is to keep fallback. Regarding configuration: enableWebp with default true?

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

@stereobooster
Copy link
Contributor Author

stereobooster commented Sep 12, 2023

  • Unconnected: in layouts/_default/single.html there is figcaption tag without figure. Is this intentional?
  • Also I wonder if this code will upscale images, if for example it is 700px?

@stereobooster
Copy link
Contributor Author

I can refactor code to use https://github.com/stereobooster/hugo-ideal-image if you want

@jpanther jpanther added the enhancement New feature or request label Oct 22, 2023
@@ -24,7 +25,7 @@
{{ with $resource }}
<figure>
<picture>
{{ if ne .MediaType.SubType "svg" }}
{{ if (and (ne .MediaType.SubType "svg") $webp) }}
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

@stereobooster stereobooster Oct 25, 2023

Choose a reason for hiding this comment

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

@jpanther
Copy link
Owner

I can refactor code to use https://github.com/stereobooster/hugo-ideal-image if you want

I'm not particularly interested in including external modules into the base theme.

@stereobooster
Copy link
Contributor Author

It's not a module, just an example implementation. I will inline all the code (which is picture.html) and then reuse it everywhere

@stereobooster
Copy link
Contributor Author

closed in favour of #693

@stereobooster stereobooster deleted the picture branch November 26, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants