-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
themes/hello-friend-ng/layouts/partials/singleImage-embed.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ $image := . }} | ||
{{ $full := index ($image.Links) 0 }} | ||
{{ $alt := $image.Caption }} | ||
{{ if not $alt}} | ||
{{ $alt = $image.Title }} | ||
{{ end }} | ||
{{ $srcset := "" }} | ||
{{ range $image.Links }} | ||
{{ $srcset = printf "%s %s %vw," $srcset .Url .Width }} | ||
{{ end }} | ||
{{ $srcset = trim $srcset ","}} | ||
<!-- start embed --> | ||
<a class="gallery-item" href="{{ $full.Url }}" data-pswp-src="{{ $full.Url }}" data-pswp-width="{{ $full.Width }}" | ||
data-pswp-height="{{ $full.Height }}" title="{{ .Title }}" itemscope itemtype="https://schema.org/ImageObject" | ||
style="aspect-ratio: {{ $full.Width }} / {{ $full.Height }}" {{ printf "data-pswp-srcset=%q" $srcset | safeHTMLAttr | ||
}}> | ||
<img loading="lazy" width="{{ $full.Width }}" height="{{ $full.Height }}" src="{{ $full.Url }}" alt="{{ $alt }}" | ||
srcset="{{ $srcset }}" > | ||
</a> | ||
<!-- end embed --> |
This file contains 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