Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Access metadata from markdown

Started by charlie 8 years ago · 1 replies · 1027 views
8 years ago

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!
charlie

8 years ago

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 🙂

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

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 99 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 186 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 62 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 257 1 year ago