Skip to content

Commit

Permalink
fixing embedded image
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncanma committed May 7, 2024
1 parent a65e0e9 commit 2c474aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions themes/hello-friend-ng/layouts/partials/singleImage-embed.html
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 -->
4 changes: 2 additions & 2 deletions themes/hello-friend-ng/layouts/shortcodes/albumImage.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ $album := .Site.GetPage $albumName }}
{{ $image := index $album.Params.Pictures $imageIndex }}
{{ with $image }}
<div class="photo-list" >
{{ partial "singleImage.html" . }}
<div class="photo-list">
{{ partial "singleImage-embed.html" . }}
</div>
{{ end }}

0 comments on commit 2c474aa

Please sign in to comment.