-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
tpl/images: Add images.QR function #13212
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98c9ccc to
d0029d8
Compare
bep
requested changes
Jan 2, 2025
ae08c96 to
fa99b36
Compare
bep
reviewed
Jan 3, 2025
bep
reviewed
Jan 3, 2025
bep
reviewed
Jan 3, 2025
bep
reviewed
Jan 3, 2025
76dc38c to
5ca121f
Compare
bep
reviewed
Jan 5, 2025
|
I'll handle styling of the example images on the docs site, so if you build the docs from this repo the examples will be stretched. |
c1e7ff1 to
58c4771
Compare
bep
reviewed
Jan 5, 2025
bep
reviewed
Jan 5, 2025
bep
approved these changes
Jan 6, 2025
|
Just in case anyone is stumbling upon this feature -- thank you for it btw! -- and is thinking "dammit, no way to change the colors of the QR code to adjust for dark/light themes!", I got you covered: <div id="qrcode">
{{ with (images.QR .Permalink (dict "level" "high" "scale" 3)) }}
<img src="{{ .RelPermalink }}"
width="{{ .Width }}"
height="{{ .Height }}"
alt="QR code linking to {{ $.Permalink }}"
class="qrcode-light"
loading="lazy">
{{ with . | images.Filter images.Invert }}
<img src="{{ .RelPermalink }}"
width="{{ .Width }}"
height="{{ .Height }}"
alt="QR code linking to {{ $.Permalink }}"
class="qrcode-dark"
loading="lazy">
{{ end }}
{{ end }}
</div>@media (prefers-color-scheme: dark) {
#qrcode > .qrcode-light {
display: none;
}
}
@media (prefers-color-scheme: light) {
#qrcode > .qrcode-dark {
display: none;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #13205
Note that this uses
(create.Client).FromStringunder the covers, which seemed a lot simpler than creating aFromBytesorFromImagemethod.Site and theme authors should test the rendered image per the documentation: