Enhancement: Extend Media Configuration #317

Closed
opened 2026-10-05 02:39:49 +02:00 by adam · 4 comments
Owner

Is your feature request related to a problem? Please describe.

I was trying to turn my art shortcode into a snippet and thought it would be useful to be able to use the media snippet feature, especially since most of the fields for that shortcode are captured in the existing details for media files. In my case, I need two fields that aren't available for media files: extra classes to apply (which will always be context specific, not part of the details for the media file itself) and a content warning (which should always be used for that media and belongs in the media's details, if possible).

However, if I want to take advantage of the (extremely good!) functionality for media snippets, I can't define any extra fields for the snippet beyond the placeholders, as far as I can tell, and I would have to respecify the content warning every time I wanted to use the snippet, which could lead to drifting verbiage.

Describe the solution you'd like

I would like to be able to use media placeholders alongside custom inputs for media snippets and extend the details I can supply for media files in general.

If I could specify a snippet like this:

"Art": {
  "description": "Add art as a figure with an optional content warning.",
  "body": "{{< art src=\"[[&mediaUrl]]\" alt=\"[[&alt]]\" class=\"[[classes]]\" content_warning=\"[[&contentWarning]]\" />}}",
  "isMediaSnippet": true,
  "fields": [
    {
      "name": "classes",
      "title": "Class List: Specify any classes to add to the block in a space separated list.",
      "type": "string",
      "single": true,
      "default": ""
    }
  ]
}

And a setting in frontmatter.json (example name, probably not a good one) like this:

"frontMatter.media.extraDetailFields": [
  {
    "title": "Content Warning",
    "name": "contentWarning",
    "type": "string",
    "single": false
  }
]

Then when I select the Art media snippet, it would prompt me with a modal for the non-details fields (in this case, just classes) and otherwise work as the current ones do.

Describe alternatives you've considered

I could define a data set for my media which includes the content warning and always reference that (though snippets don't yet support this, I think). I could define a normal snippet and lose the media selection/automatic placeholders, which is still better than hand-authoring the shortcode, but not nearly as good as the UX for media snippets.

Additional context

N/A

**Is your feature request related to a problem? Please describe.** I was trying to turn my [art shortcode][01] into a snippet and thought it would be useful to be able to use the media snippet feature, especially since _most_ of the fields for that shortcode are captured in the existing details for media files. In my case, I need two fields that aren't available for media files: extra classes to apply (which will always be context specific, not part of the details for the media file itself) and a content warning (which _should_ always be used for that media and belongs in the media's details, if possible). However, if I want to take advantage of the (extremely good!) functionality for media snippets, I _can't_ define any extra fields for the snippet beyond the placeholders, as far as I can tell, and I would have to respecify the content warning every time I wanted to use the snippet, which could lead to drifting verbiage. **Describe the solution you'd like** I would like to be able to use media placeholders alongside custom inputs for media snippets and extend the details I can supply for media files in general. If I could specify a snippet like this: ```json "Art": { "description": "Add art as a figure with an optional content warning.", "body": "{{< art src=\"[[&mediaUrl]]\" alt=\"[[&alt]]\" class=\"[[classes]]\" content_warning=\"[[&contentWarning]]\" />}}", "isMediaSnippet": true, "fields": [ { "name": "classes", "title": "Class List: Specify any classes to add to the block in a space separated list.", "type": "string", "single": true, "default": "" } ] } ``` And a setting in `frontmatter.json` (example name, probably not a good one) like this: ```json "frontMatter.media.extraDetailFields": [ { "title": "Content Warning", "name": "contentWarning", "type": "string", "single": false } ] ``` Then when I select the `Art` media snippet, it would prompt me with a modal for the non-details fields (in this case, just classes) and otherwise work as the current ones do. **Describe alternatives you've considered** I could define a data set for my media which includes the content warning and always reference that (though snippets don't yet support this, I think). I could define a normal snippet and lose the media selection/automatic placeholders, which is _still better_ than hand-authoring the shortcode, but not nearly as good as the UX for media snippets. **Additional context** N/A [01]: https://github.com/platenio/hugo-platen/blob/main/layouts/shortcodes/art.html <!-- github-sync-id:1360957593 -->
adam closed this issue 2026-10-05 02:39:49 +02:00
Author
Owner

Thanks, @michaeltlombardi, for the suggestion. This makes sense to bring the functionality from normal snippets over to media snippets + have some further enhancements as you suggest with the warnings.

Thanks, @michaeltlombardi, for the suggestion. This makes sense to bring the functionality from normal snippets over to media snippets + have some further enhancements as you suggest with the warnings. <!-- github-comment-id:1236626445 -->
Author
Owner

Good news, I have just implemented this enhancement, enabling you to use extra fields in your media snippets. If none are defined, it works like before, but when you define custom fields for your snippet, it will open the form.

Xnapper-2022-09-09-18 00 01

Info: the media placeholders will also appear as a field that can be modified. This is intentional, so you have the option to override its value.

Good news, I have just implemented this enhancement, enabling you to use extra fields in your media snippets. If none are defined, it works like before, but when you define custom fields for your snippet, it will open the form. ![Xnapper-2022-09-09-18 00 01](https://user-images.githubusercontent.com/2900833/189392576-01472e96-7863-4c89-a3a2-121ca6215f6f.png) > **Info**: the media placeholders will also appear as a field that can be modified. This is intentional, so you have the option to override its value. <!-- github-comment-id:1242164387 -->
Author
Owner

@estruyf confirmed working in latest beta! This is incredibly good!

Screenshot of the custom art snippet side by side with the definition of the snippet in the config

@estruyf confirmed working in latest beta! This is _incredibly_ good! ![Screenshot of the custom art snippet side by side with the definition of the snippet in the config](https://user-images.githubusercontent.com/14190564/189498931-7e8dc30a-f4f0-4c65-bee4-c69688ba5ee5.png) <!-- github-comment-id:1242792961 -->
Author
Owner

Great 😍 - think I'll use this feature a lot as well!

Great 😍 - think I'll use this feature a lot as well! <!-- github-comment-id:1242795164 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#317