Hello everyone,
I am in the process of building an image gallery from JPGs and try to read some Exif tags to put them in the HTML.
This image gallery is set in a shortcode and when I try to read the Exif, Hugo raise an error “executing “shortcodes/gallery.html” at <.Exif>: error calling Exif: unexpected end of JSON input”.
What’s bother me, is that I use the same code to reads Exif in an other shortcode and it’s work pretty well with the sames images.
The full code of the gallery shortcode :
{{- $folderPath := printf "%s/*" (.Get "folder") }}
{{- $originalPage := .Site.GetPage "page" .Page.Path }}
{{- $originalImages := $originalPage.Resources.Match $folderPath }}
<div style='clear:both'></div>
<div id="psgal_7_1" class="psgal gallery-columns-3 gallery-size-thumbnail" itemscope itemtype="http://schema.org/ImageGallery">
{{- range ($originalImages) }}
{{- $thumbnail := .Resize "320x" }}
{{ printf "%s" .Exif.Tags.Make }}
<figure itemscope itemtype="http://schema.org/ImageObject" class="msnry_item">
{{- $mediumw := default "1200x" }}
{{- $medium := (.Resize $mediumw) }}
<a href="{{ $medium.RelPermalink | absURL }}" itemprop="contentUrl" data-size="{{ $medium.Width }}x{{ $medium.Height }}" data-caption="" >
<img src="{{ $thumbnail.Permalink }}" itemprop="thumbnail" alt="" />
</a>
<figcaption class="photoswipe-gallery-caption" itemprop="caption description"><span itemprop="copyrightHolder"></span>
</figcaption>
</figure>
{{- end }}
</div>
The code used in another shortcode, and this one work…
{{- $originalPage := $.Site.GetPage "page" $.Page.Path }}
{{- $originalImage := $originalPage.Resources.GetMatch $imagePath }}
{{ printf "%s" $originalImage.Exif.Tags.Make }}
I don’t know what’s wrong with this code…
Hugo version :
Hugo Static Site Generator v0.58.3-4AAC02D4 windows/amd64 BuildDate: 2019-09-19T15:29:19Z*
GOOS=“windows”
GOARCH=“amd64”
GOVERSION=“go1.13”