les figures resizent automatiquement les images et les convertissent en webp
Some checks are pending
/ test (push) Waiting to run

This commit is contained in:
gribse 2025-05-06 22:31:56 +02:00
parent 9fbc692ca0
commit 2695d07949
3 changed files with 11 additions and 4 deletions

View file

@ -8,7 +8,11 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
{{- $.Page.Scratch.Add "figurecount" 1 -}}
<!-- use either src or link-thumb for thumbnail image -->
{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }}
{{- $thumbResource := $.Page.Resources.Get $thumb }}
{{- $thumbResource := $.Page.Resources.GetMatch $thumb }}
{{- $fitSize := .Get "size" | default "400" }}
{{- if $thumbResource }}
{{- $thumbResource = $thumbResource.Fit (printf "%[1]sx%[1]s webp q85" $fitSize) -}}
{{- end }}
<div class="box{{ with .Get "caption-position" }} fancy-figure caption-position-{{.}}{{end}}{{ with .Get "caption-effect" }} caption-effect-{{.}}{{end}}" {{ with .Get "width" }}style="max-width:{{.}}"{{end}}>
<figure {{ with .Get "class" }}class="{{.}}"{{ end }} itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img"{{ if .Parent }} style="background-image: url('{{ if $thumbResource }}{{ $thumbResource.RelPermalink }}{{ else }}{{ $thumb | relURL }}{{ end }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>