-
-
-
-
+ {{ if $image.exists }}
+
{{ end }}
{{ partial "article/components/details" . }}
diff --git a/layouts/partials/article-list/tile.html b/layouts/partials/article-list/tile.html
index 9a58d4b..6b4375a 100644
--- a/layouts/partials/article-list/tile.html
+++ b/layouts/partials/article-list/tile.html
@@ -1,12 +1,19 @@
-
-
-
+
+ {{ if $image.exists }}
+
+ {{ if $image.local }}
+ {{- $imageRaw := $image.src | resources.Fingerprint "md5" -}}
+ {{- $thumbnail := $imageRaw.Fill .size -}}
+
+
+ {{ else }}
+
+ {{ end }}
+
{{ end }}
diff --git a/layouts/partials/article/components/details.html b/layouts/partials/article/components/details.html
index 4349d61..0e3ff50 100644
--- a/layouts/partials/article/components/details.html
+++ b/layouts/partials/article/components/details.html
@@ -1,15 +1,14 @@
-{{ $i := .Params.image }}
+{{ $image := partial "helper/image" . }}
{{ $context := . }}
-
{{ with $categories := .Params.categories }}
{{ range $categories }}
- {{ if $i }}
- {{- $image := partial "helper/image" $context | resources.Fingerprint "md5" -}}
- {{- $20x := $image.Fill "20x20 smart" -}}
+ {{ if and $image.exists $image.local }}
+ {{- $imageRaw := $image.src | resources.Fingerprint "md5" -}}
+ {{- $20x := $imageRaw.Fill "20x20 smart" -}}
{{ . | humanize }}
+ data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">{{ . | humanize }}
{{ else }}
{{ . | humanize }}
{{ end }}
diff --git a/layouts/partials/article/components/header.html b/layouts/partials/article/components/header.html
index 1bd5663..14f6da2 100644
--- a/layouts/partials/article/components/header.html
+++ b/layouts/partials/article/components/header.html
@@ -1,16 +1,19 @@
- {{ if .Params.image }}
- {{- $image := partial "helper/image" . -}}
+ {{ $image := partial "helper/image" . }}
- {{- $tablet := $image.Resize "1024x" -}}
- {{- $desktop := $image.Resize "2000x" -}}
+ {{ if $image.exists }}
+
+ {{ if $image.local }}
+ {{- $tablet := $image.src.Resize "1024x" -}}
+ {{- $desktop := $image.src.Resize "2000x" -}}
-
{{ end }}
{{ partial "article/components/details" . }}
diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html
index dd298c2..654c55c 100644
--- a/layouts/partials/head/opengraph.html
+++ b/layouts/partials/head/opengraph.html
@@ -40,11 +40,15 @@
{{- end -}}
{{- end -}}
-{{- if .Params.image -}}
- {{ $image := partial "helper/image" . }}
+{{ $image := partial "helper/image" . }}
+{{- if $image.exists -}}
+ {{ $imagePermalink := $image.src }}
+ {{ if $image.local }}
+ {{ $imagePermalink = absURL $image.src.RelPermalink }}
+ {{ end }}
-
-
+
+
{{- else if .Site.Params.opengraph.defaultImage -}}
{{ $image := resources.Get .Site.Params.opengraph.defaultImage }}
diff --git a/layouts/partials/helper/image.html b/layouts/partials/helper/image.html
index 308a36c..4136e67 100644
--- a/layouts/partials/helper/image.html
+++ b/layouts/partials/helper/image.html
@@ -1,2 +1,31 @@
-{{- $image := .Resources.GetMatch (printf "%s" (.Params.image | safeURL)) -}}
-{{ return $image }}
\ No newline at end of file
+{{ $result := dict "exists" false "local" false "isDefault" false }}
+{{ $imageField := .Params.image }}
+{{ if $imageField }}
+
+ {{ $result = merge $result (dict "exists" true) }}
+
+ {{ if strings.HasPrefix $imageField "http" }}
+
+ {{ $result = merge $result (dict "src" $imageField) }}
+ {{ else }}
+ {{ $pageResourceImage := .Resources.GetMatch (printf "%s" ($imageField | safeURL)) }}
+ {{ $siteResourceImage := resources.GetMatch (printf "%s" ($imageField | safeURL)) }}
+
+ {{ if $pageResourceImage }}
+
+ {{ $result = merge $result (dict "local" true) }}
+ {{ $result = merge $result (dict "src" $pageResourceImage) }}
+ {{ else if $siteResourceImage }}
+
+ {{ $result = merge $result (dict "local" true) }}
+ {{ $result = merge $result (dict "src" $siteResourceImage) }}
+ {{ else }}
+
+ {{ errorf "Failed loading image: %q" $imageField }}
+ {{ $result = merge $result (dict "exists" false) }}
+ {{ end }}
+ {{ end }}
+
+{{ end }}
+
+{{ return $result }}
\ No newline at end of file
-
-
+
+ {{ else }}
+
+ {{ end }}
+