feat(helper/image): new return format

This commit is contained in:
Jimmy Cai
2020-09-11 16:01:01 +02:00
parent 3e18e165e0
commit cfd4cdb731
8 changed files with 30 additions and 35 deletions
+3 -3
View File
@@ -4,14 +4,14 @@
{{ if $image.exists }}
<div class="article-image">
{{ if $image.local }}
{{- $imageRaw := $image.src | resources.Fingerprint "md5" -}}
{{ if $image.resource }}
{{- $imageRaw := $image.resource | resources.Fingerprint "md5" -}}
{{- $thumbnail := $imageRaw.Fill .size -}}
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}"
loading="lazy" data-key="{{ .context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">
{{ else }}
<img src="{{ $image.src }}" loading="lazy" data-key="{{ .context.Slug }}" data-hash="{{ $image.src }}"/>
<img src="{{ $image.permalink }}" loading="lazy" data-key="{{ .context.Slug }}" data-hash="{{ $image.permalink }}"/>
{{ end }}
</div>
{{ end }}