Add exif hero images
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -10,7 +10,7 @@ img {
|
|||||||
|
|
||||||
figcaption {
|
figcaption {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 0.5rem;
|
padding-top: 1rem;
|
||||||
color: color-mix(in srgb, var(--text) 50%, var(--background));
|
color: color-mix(in srgb, var(--text) 50%, var(--background));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
{{ $data := partial "components/image/process.html" (dict "page" .Page "src" .Destination) }}
|
{{ $data := partial "components/image/process.html" (dict "page" .Page "src" .Destination) }}
|
||||||
{{ partial "components/image/index.html" (merge $data (dict "caption" .Text "alt" .Title)) }}
|
{{ partial "components/image/index.html" (merge $data (dict "caption" .Text "title" .Title)) }}
|
||||||
{{- /* chomp trailing newline */ -}}
|
{{- /* chomp trailing newline */ -}}
|
||||||
|
25
layouts/_shortcodes/exif-image.html
Normal file
25
layouts/_shortcodes/exif-image.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{{ $src := "" }}
|
||||||
|
{{ if .IsNamedParams }}
|
||||||
|
{{ $src = .Get "src" }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $src = .Get 0 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $title := "" }}
|
||||||
|
{{ if .IsNamedParams }}
|
||||||
|
{{ $title = .Get "title" }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $title = .Get 1 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $alt := "" }}
|
||||||
|
{{ if .IsNamedParams }}
|
||||||
|
{{ $alt = .Get "alt" }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $alt = .Get 1 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $data := partial "components/image/process.html" (dict "page" .Page "src" $src) }}
|
||||||
|
{{ $caption := partial "components/image/exif.html" $data.original }}
|
||||||
|
{{ partial "components/image/index.html" (merge $data (dict "caption" $caption "title" $title "alt" $alt)) }}
|
||||||
|
{{- /* chomp trailing newline */ -}}
|
@@ -4,5 +4,12 @@
|
|||||||
|
|
||||||
{{ $hero := partial "components/hero/process.html" .Params.hero }}
|
{{ $hero := partial "components/hero/process.html" .Params.hero }}
|
||||||
{{ $data := partial "components/image/process.html" (dict "page" .Page "src" $hero.src) }}
|
{{ $data := partial "components/image/process.html" (dict "page" .Page "src" $hero.src) }}
|
||||||
{{ partial "components/image/index.html" (merge $data $hero) }}
|
|
||||||
|
{{ $final := merge $data $hero }}
|
||||||
|
{{ if $hero.exif }}
|
||||||
|
{{ $caption := partial "components/image/exif.html" $data.original }}
|
||||||
|
{{ $final = merge $final (dict "caption" $caption) }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ partial "components/image/index.html" $final }}
|
||||||
</section>
|
</section>
|
||||||
|
@@ -2,14 +2,16 @@
|
|||||||
{{- $caption := "" -}}
|
{{- $caption := "" -}}
|
||||||
{{- $title := "" -}}
|
{{- $title := "" -}}
|
||||||
{{- $alt := "" -}}
|
{{- $alt := "" -}}
|
||||||
|
{{- $exif := false -}}
|
||||||
|
|
||||||
{{- if reflect.IsMap . -}}
|
{{- if reflect.IsMap . -}}
|
||||||
{{- $src = .src -}}
|
{{- $src = .src -}}
|
||||||
{{- $caption = .caption | default "" -}}
|
{{- $caption = .caption -}}
|
||||||
{{- $title = .title | default $caption | plainify -}}
|
{{- $title = .title -}}
|
||||||
{{- $alt = .alt | default $title | plainify -}}
|
{{- $alt = .alt -}}
|
||||||
|
{{- $exif = .exif | default false -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- $src = . -}}
|
{{- $src = . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- return (dict "src" $src "caption" $caption "title" $title "alt" $alt) -}}
|
{{- return dict "src" $src "caption" $caption "title" $title "alt" $alt "exif" $exif -}}
|
||||||
|
22
layouts/partials/components/image/exif.html
Normal file
22
layouts/partials/components/image/exif.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{{ $exif := .Exif.Tags }}
|
||||||
|
|
||||||
|
{{ $make := $exif.Make }}
|
||||||
|
{{ $model := $exif.Model }}
|
||||||
|
|
||||||
|
{{ $lensMake := $exif.LensMake }}
|
||||||
|
{{ $lensModel := $exif.LensModel }}
|
||||||
|
|
||||||
|
{{ $lens := "" }}
|
||||||
|
{{ if ne $make $lensMake }}
|
||||||
|
{{ $lens = printf "%s %s" $lensMake $lensModel }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $lens = $lensModel }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $focal := printf "%.1f" (float $exif.FocalLength) }}
|
||||||
|
{{ $focal35 := printf "%.1f" (float $exif.FocalLengthIn35mmFormat) }}
|
||||||
|
{{ $shutter := printf "%d" $exif.ExposureTime }}
|
||||||
|
{{ $aperture := printf "%d" $exif.FNumber }}
|
||||||
|
{{ $iso := printf "%d" $exif.ISO }}
|
||||||
|
|
||||||
|
{{ return printf "%s %s, %s @ %s mm (%s mm), %s s, f/%s, ISO %s" $make $model $lens $focal $focal35 $shutter $aperture $iso }}
|
@@ -20,4 +20,4 @@
|
|||||||
{{- $thumb = $original | images.Filter (images.Process "webp q75") -}}
|
{{- $thumb = $original | images.Filter (images.Process "webp q75") -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- return (dict "original" $original "full" $full "thumb" $thumb) -}}
|
{{- return dict "original" $original "full" $full "thumb" $thumb -}}
|
||||||
|
Reference in New Issue
Block a user