30 lines
1.2 KiB
HTML
30 lines
1.2 KiB
HTML
{{- $imageURL := .Get 0 -}}
|
|
{{- $alignment := .Get 1 | default "center" -}}
|
|
{{- $title := .Get 2 | default "" -}}
|
|
{{- $description := .Get 3 | default "" -}}
|
|
{{- $attribution := .Get 4 | default "" -}}
|
|
{{- $imageURL := printf "%s?raw=true" $imageURL -}}
|
|
{{- $remoteImage := resources.GetRemote $imageURL -}}
|
|
{{- $hash := md5 $imageURL -}}
|
|
{{- $extension := path.Ext $imageURL -}}
|
|
{{- $cleanFilename := printf "%s%s" $hash $extension -}}
|
|
{{- $cleanFilename := replace $cleanFilename "?raw=true" "" -}}
|
|
{{- $localImage := $remoteImage | resources.Copy (printf "remote-images/%s" $cleanFilename) -}}
|
|
{{- $width := (cond (eq $alignment "center") "1024x" "500x") -}}
|
|
{{- $resizedImage := $localImage.Resize $width -}}
|
|
<figure class="custom-image {{ $alignment }}">
|
|
<a href="{{ $localImage.RelPermalink }}" title="Cliquez pour agrandir l'image">
|
|
<img src="{{ $resizedImage.RelPermalink }}" alt="{{ $title }}" title="{{ $title }}" />
|
|
</a>
|
|
{{- with $attribution }}
|
|
<p class="details">
|
|
<strong>Attribution :</strong>
|
|
<em>{{ . | markdownify }}</em>
|
|
</p>
|
|
{{- end }}
|
|
{{- with $description }}
|
|
<figcaption>
|
|
<p>{{ .| markdownify }}</p>
|
|
</figcaption>
|
|
{{- end }}
|
|
</figure> |