Encoding an image using base64 in frontmatter

I’ve set up a custom output format to create some vcards and it works as intended. One thing that I am trying to do is add an image to it and from what I understand the image needs to be a base64 encoded string.

In my frontmatter for each vcard being created, I have an image param that has the filename.

I have the following in my template file:

PHOTO;TYPE=JPEG;ENCODING=b:{{ .Params.image | base64Encode }}

What this does is encode the string of the filename itself. What I need is to encode the actual image. Can someone point me in the right direction? I’ve been trying to figure this out for hours.


Under “Content” there’s an example.

1 Like

Oh man. Thank you!!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.