feat(helper/image): new return format
This commit is contained in:
@@ -16,12 +16,12 @@
|
||||
|
||||
{{ if $image.exists }}
|
||||
<div class="article-image">
|
||||
{{ if $image.local }}
|
||||
{{- $thumbnail := $image.src.Fill "120x120" -}}
|
||||
{{ if $image.resource }}
|
||||
{{- $thumbnail := $image.resource.Fill "120x120" -}}
|
||||
<img src="{{ $thumbnail.RelPermalink }}" width="{{ $thumbnail.Width }}"
|
||||
height="{{ $thumbnail.Height }}" loading="lazy">
|
||||
{{ else }}
|
||||
<img src="{{ $image.src }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<article class="{{ if .Params.image }}has-image{{ end }}">
|
||||
{{ $image := partial "helper/image" . }}
|
||||
|
||||
{{ $image := partial "helper/image" . }}
|
||||
<article class="{{ if $image.exists }}has-image{{ end }}">
|
||||
{{ if $image.exists }}
|
||||
<div class="article-image">
|
||||
<a href="{{ .Permalink }}">
|
||||
{{ if $image.local }}
|
||||
{{- $thumbnail := $image.src.Fill "800x250" -}}
|
||||
{{- $thumbnailRetina := $image.src.Fill "1600x500" -}}
|
||||
{{ if $image.resource }}
|
||||
{{- $thumbnail := $image.resource.Fill "800x250" -}}
|
||||
{{- $thumbnailRetina := $image.resource.Fill "1600x500" -}}
|
||||
|
||||
<img src="{{ $thumbnail.RelPermalink }}"
|
||||
srcset="{{ $thumbnail.RelPermalink }} 1x, {{ $thumbnailRetina.RelPermalink }} 2x"
|
||||
width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" loading="lazy"
|
||||
alt="Featured image of post {{ .Title }}" />
|
||||
{{ else }}
|
||||
<img src="{{ $image.src }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||
{{ end }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user