Is the EXIF Tag UserComments supported by Hugo?
Is there a list of what is returned by use of the Exif function ?
Thanks
Is the EXIF Tag UserComments supported by Hugo?
Is there a list of what is returned by use of the Exif function ?
Thanks
The EXIF tag is named “UserComment” (singular).
{{ with resources.Get "a.jpg" }}
{{ with .Exif }}
{{ .Tags.UserComment }}
{{ end }}
{{ end }}
To list all EXIF tags:
{{ with resources.Get "a.jpg" }}
{{ with .Exif }}
{{ range $k, $v := .Tags }}
{{ $k }}: {{ $v }}<br>
{{ end }}
{{ end }}
{{ end }}
To include/exclude EXIF tags, see:
https://gohugo.io/content-management/image-processing/#exif-data.
Note that the “UserComment” EXIF tag is a bit strange, and will probably start with a string indicating the encoding (e.g., ASCII). The “ImageDescription” EXIF tag is probably a better choice.
Many thanks
I would use the ImageDescription but that seems to be where the Title value is coming from. I need to pass in two EXIF strings - one for the image title and one for the image’s description - hence I was looking at UserComment
It would be better to use IPTC metadata, since they are offering fine-grand control and more fields. Unfortunately, Hugo doesn’t (yet?) support them.
I agree - all the metadata I want to access is in IPTC fields, so I am having to try and squeeze it in the EXIF fields to get at it. Not elegant
This might also be helpful (describes other writable fields that Hugo can read):
https://discourse.gohugo.io/t/generate-html-from-image-metadata/48250/9
That thread also discusses the use of exiftool to create a data file that you can then access with site.Data.something, probably using the image path as the key.
Thanks that gave me some better options
One related question…
I am going to generally use the Artist field for one of my IPTC → EXIF changes, but sometimes it may be a different field.
What is the right right to code Hugo in a Shortcut to have the field as a variable - see code below
{{ $extendedCaptionField := .Get "extendedCaptionField" | default (.Site.Params.justifiedGrid.extendedCaptionField | default "") }}
{{ $extendedCaption := "" }}
{{ with $image.Exif }}
{{ with .Tags.Artist }} <------- Use $extendedCaptionField here instead of Artist
{{ $extendedCaption = . }}
{{ end }}
{{ end }}
Thanks
Sorry, I don’t understand the question.
Sorry.
Where currently I am using .Tags.Artist I want to use .Tags.$extendedCaptionField so I can use different fields as required, but that fails (due to my limited GO knowledge)
Hope that makes better sense?
Look at the index
function.
Brilliant thanks.
Learning more each day
Another quick question if I may.
I am trying to test if the tag field is in the Exif and if so set the value; if not leave it blank. I can do this with a few lines of code, but as park of the learning process I am trying to be code-efficient; but not sure I am fully understanding INDEX and WITHs
Can you tell me what I am doing wrong with the below?
Thanks
{{ $extendedCaption := ""}}
{{ with $image.Exif }}
{{ with index .Tags $extendedCaptionField }}
{{ $extendedCaption := . }}
{{ end }}
{{ end }}
I’m not sure what the rest of the code looks like, but this bit is clearly wrong:
{{ with index .Tags $extendedCaptionField }}
{{ $extendedCaption := . }}
{{ end }}
Change it to:
{{ with index .Tags $extendedCaptionField }}
{{ $extendedCaption = . }}
{{ end }}
See this FAQ.
Wonderful thanks
Another step towards learning Go and Hugo
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.