Add exif hero images
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -10,7 +10,7 @@ img {
|
||||
|
||||
figcaption {
|
||||
text-align: center;
|
||||
padding-top: 0.5rem;
|
||||
padding-top: 1rem;
|
||||
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) }}
|
||||
{{ 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 */ -}}
|
||||
|
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 }}
|
||||
{{ $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>
|
||||
|
@@ -2,14 +2,16 @@
|
||||
{{- $caption := "" -}}
|
||||
{{- $title := "" -}}
|
||||
{{- $alt := "" -}}
|
||||
{{- $exif := false -}}
|
||||
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- $src = .src -}}
|
||||
{{- $caption = .caption | default "" -}}
|
||||
{{- $title = .title | default $caption | plainify -}}
|
||||
{{- $alt = .alt | default $title | plainify -}}
|
||||
{{- $caption = .caption -}}
|
||||
{{- $title = .title -}}
|
||||
{{- $alt = .alt -}}
|
||||
{{- $exif = .exif | default false -}}
|
||||
{{- else -}}
|
||||
{{- $src = . -}}
|
||||
{{- 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") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return (dict "original" $original "full" $full "thumb" $thumb) -}}
|
||||
{{- return dict "original" $original "full" $full "thumb" $thumb -}}
|
||||
|
Reference in New Issue
Block a user