Conditionally include photo EXIF info so the table looks all right even with missing info

This commit is contained in:
Eryn Wells 2023-01-30 12:26:06 -08:00
parent c6531e618d
commit 547e196616

View file

@ -1,16 +1,21 @@
<div class="photo-params">
<div class="container">
<table>
{{ if and .Tags.Make .Tags.Model }}
<thead>
<td class="make-model" colspan=4>{{ .Tags.Make }} {{ .Tags.Model }}</td>
</thead>
{{ end }}
<tr>
{{ if and .Lat .Long }}
<td colspan="2" class="location">
{{ $lat := float .Lat }}{{ $latDir := cond (eq $lat 0) "" (cond (gt $lat 0) "N" "S") }}
<data class="latitude" value="{{ $lat }}">{{ .Lat | lang.FormatNumber (cond (ne $lat 0) 3 0) }}º{{ $latDir }}</data>,
{{ $long := float .Long }}{{ $longDir := cond (eq $long 0) "" (cond (gt $long 0) "E" "W") }}
<data class="longitude" value="{{ $long }}">{{ .Long | lang.FormatNumber (cond (ne $long 0) 3 0) }}º{{ $longDir }}</data>
</td>
{{ end }}
{{ if and .Tags.PixelXDimension .Tags.PixelYDimension }}
<td colspan="2" class="size">
{{ $widthpx := .Tags.PixelXDimension }}
{{ $heightpx := .Tags.PixelYDimension }}
@ -19,13 +24,16 @@
<data value="{{ $megapixels }}">{{ $megapixels | lang.FormatNumber 0 }} MP</data> • {{ $widthpx }} × {{ $heightpx }}
{{ end }}
</td>
{{ end }}
</tr>
{{ if or .Tags.ISOSpeedRatings .Tags.FocalLengthIn35mmFilm .Tags.FNumber .Tags.ExposureTime }}
<tr class="exposure-attributes">
<td class="iso">{{ with .Tags.ISOSpeedRatings }}ISO {{ . }}{{ end }}</td>
<td class="focal-length">{{ with .Tags.FocalLengthIn35mmFilm }}{{ . }} mm{{ end }}</td>
<td class="f-number">{{ with .Tags.FNumber }}ƒ{{ . }}{{ end }}</td>
<td class="exposure-time">{{ with .Tags.ExposureTime }}{{ . }} s{{ end }}</td>
</tr>
{{ end }}
</table>
</div>
</div>