Access metadata from markdown

New to Grav, and enjoying it quite a bit so far. I think this is a style question as well as a technical one.

I’m trying to add captions to photos, and have them be a bit ‘smarter’. For example, if I add a image.jpg.meta.yaml with a “caption” field, it would simply add a div with a caption, but an “instagram” field would caption and create a link to the original.

I’m currently adding all images via markdown in the editor, since I want control of where they go, relative to the rest of the text. Is it possible to access the image metadata inside of markdown?

Secondly, is it silly to try to accomplish this in markdown, and is there a way to solve this via a plugin or something? If I still place the images via markdown, can I access their metadata in the twig template after they’ve been processed?

How would you all tackle this?

Thank you!

I don’t work a lot with media myself, so maybe someone more expert will chime in.

If you have the metadata in YAML or JSON files, then you could leverage something like the Import plugin to load that into the frontmatter and drop it into your Markdown.

If it’s something you want to pull from the image file itself, then you’d need a plugin. I don’t see an exif plugin currently available, but you could write one :slight_smile:

I’m not crystal clear on your requirements, though. More specific information could lead to a more specific response.