63 lines
2.2 KiB
HTML
63 lines
2.2 KiB
HTML
{{- $imgPath := (urls.Parse .Destination).Path -}}
|
|
{{- $imgName := path.Base $imgPath | replaceRE "\\.[^.]+$" "" -}} {{/* Supprime l'extension */}}
|
|
{{- $dataPath := printf "data/images/%s.yaml" $imgName -}}
|
|
{{- $dataFile := .Page.Resources.Get $dataPath -}}
|
|
{{- $data := dict -}}
|
|
{{- if $dataFile }}
|
|
{{- with $dataFile.Content | transform.Unmarshal -}}
|
|
{{- $data = . -}}
|
|
{{- end -}}
|
|
{{- end }}
|
|
{{- $alt := .PlainText | default $data.title | default "" -}}
|
|
{{- $title := .Title | default $data.title | default .Page.Title -}}
|
|
{{- $description := default $data.description | default $title -}}
|
|
{{- $image := false -}}
|
|
{{- $imagePathLower := lower $imgPath -}}
|
|
{{- if or (strings.HasSuffix $imagePathLower ".yaml") (strings.HasSuffix $imagePathLower ".yml") -}}
|
|
{{- $imageDataFile := .Page.Resources.Get $imgPath -}}
|
|
{{- if $imageDataFile -}}
|
|
{{- with $imageDataFile.Content | transform.Unmarshal -}}
|
|
{{- with index . "file" -}}
|
|
{{- $imageFilePath := strings.TrimSpace (printf "%v" .) -}}
|
|
{{- if ne $imageFilePath "" -}}
|
|
{{- $image = $.Page.Resources.Get $imageFilePath -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- $image = .Page.Resources.Get $imgPath -}}
|
|
{{- end -}}
|
|
{{- with $image -}}
|
|
{{- $resolvedImage := . -}}
|
|
{{- $display := $resolvedImage }}
|
|
{{- if and $display (ne $display.MediaType.SubType "svg") (gt $display.Height 810) }}
|
|
{{- $display = $resolvedImage.Resize "x810" -}}
|
|
{{- end }}
|
|
<figure>
|
|
{{- with $description }}
|
|
<figcaption>
|
|
<p>{{ . | markdownify }}</p>
|
|
</figcaption>
|
|
{{- end }}
|
|
<a href="{{ $resolvedImage.RelPermalink }}" title="Cliquez pour agrandir l'image">
|
|
<img src="{{ $display.RelPermalink }}" alt="{{ $alt }}" title="{{ $title }}" />
|
|
</a>
|
|
{{- if $data.prompt }}
|
|
<details>
|
|
<summary>
|
|
<strong>Attribution : {{- with $data.attribution }} <em>{{ . | markdownify }}</em>{{- end }}</strong>
|
|
</summary>
|
|
<p><strong>Prompt :</strong> <em>{{ $data.prompt }}</em></p>
|
|
</details>
|
|
{{- else }}
|
|
{{- with $data.attribution }}
|
|
<p class="details">
|
|
<strong>Attribution :</strong>
|
|
<em>{{ . | markdownify }}</em>
|
|
</p>
|
|
{{- end }}
|
|
{{- end }}
|
|
</figure>
|
|
{{- end -}}
|