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

fix: add image fix #726

Closed
wants to merge 2 commits into from
Closed

Conversation

Jh123x
Copy link
Contributor

@Jh123x Jh123x commented Nov 27, 2023

  • fix: fix img flip
  • test: test with image (No image to test)

Please let me know if anyone has an image to test

Closes #600

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for hugo-congo ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1b7361c
🔍 Latest deploy log https://app.netlify.com/sites/hugo-congo/deploys/6565e82f4b4e5f00082aceb4
😎 Deploy Preview https://deploy-preview-726--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.

@stereobooster
Copy link
Contributor

You can do something like this, to reduce repetition

    {{ $s := newScratch }}
    {{ $s.SetInMap "sizes" "330w" 330 }}
    {{ $s.SetInMap "sizes" "660w" 660 }}
    {{ if gt .Width 1024 }}
      {{ $s.SetInMap "sizes" "1024w" 1024 }}
    {{ end }}
    {{ if gt .Width 1320 }}
      {{ $s.SetInMap "sizes" "2x" 1320 }}
    {{ end }}
    {{ if le .Width 1320 }}
      {{ $s.SetInMap "sizes" (printf "%dw" .Width) .Width }}
    {{ end }}

...

          srcset="
            {{ range $key, $size := $s.Get "sizes" }}
              {{ ($img.Resize (printf "%dx webp %s" $size $rotation)).RelPermalink }} {{ $key }},
            {{ end }}"

          srcset="
            {{ range $key, $size := $s.Get "sizes" }}
              {{ ($img.Resize (printf "%dx %s" $size  $rotation)).RelPermalink }} {{ $key }},
            {{ end }}"

to reduce repetition

@Jh123x
Copy link
Contributor Author

Jh123x commented Dec 3, 2023

You can do something like this, to reduce repetition

    {{ $s := newScratch }}
    {{ $s.SetInMap "sizes" "330w" 330 }}
    {{ $s.SetInMap "sizes" "660w" 660 }}
    {{ if gt .Width 1024 }}
      {{ $s.SetInMap "sizes" "1024w" 1024 }}
    {{ end }}
    {{ if gt .Width 1320 }}
      {{ $s.SetInMap "sizes" "2x" 1320 }}
    {{ end }}
    {{ if le .Width 1320 }}
      {{ $s.SetInMap "sizes" (printf "%dw" .Width) .Width }}
    {{ end }}

...

          srcset="
            {{ range $key, $size := $s.Get "sizes" }}
              {{ ($img.Resize (printf "%dx webp %s" $size $rotation)).RelPermalink }} {{ $key }},
            {{ end }}"

          srcset="
            {{ range $key, $size := $s.Get "sizes" }}
              {{ ($img.Resize (printf "%dx %s" $size  $rotation)).RelPermalink }} {{ $key }},
            {{ end }}"

to reduce repetition

Thanks for the suggestion. I am still new to hugo and have to read up on how this works first before implementing it ><

@Jh123x Jh123x marked this pull request as draft December 22, 2023 22:46
@jpanther
Copy link
Owner

I think an issue with this implementation is that it's only dealing with one orientation. Ideally this needs to handle all the possible values and rotate the image accordingly.

@jpanther jpanther added the enhancement New feature or request label Dec 23, 2023
Copy link

This pull request has been automatically marked as stale because it has not had any recent activity.
Please review the PR history and add a reply with any requested information. If no information has been requested, it may be that this contribution does not fit with the project objectives, or does not adhere to the contributing guidelines. If this is in error, please add a reply with further details.
This PR will automatically close in 30 days if no further activity occurs.

@github-actions github-actions bot added the stale This issue or pull request has not had any recent activity label Apr 22, 2024
@Jh123x Jh123x closed this May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale This issue or pull request has not had any recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Images flipped 90 degrees
3 participants