Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Extend Media Configuration #395

Closed
michaeltlombardi opened this issue Sep 3, 2022 · 4 comments
Closed

Enhancement: Extend Media Configuration #395

michaeltlombardi opened this issue Sep 3, 2022 · 4 comments
Labels
enhancement New feature or request Project: v8.1.0

Comments

@michaeltlombardi
Copy link

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

@michaeltlombardi michaeltlombardi added the enhancement New feature or request label Sep 3, 2022
@estruyf
Copy link
Owner

estruyf commented Sep 5, 2022

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.

estruyf added a commit that referenced this issue Sep 9, 2022
@estruyf
Copy link
Owner

estruyf commented Sep 9, 2022

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.

@michaeltlombardi
Copy link
Author

@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
Copy link
Owner

estruyf commented Sep 10, 2022

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

@estruyf estruyf closed this as completed Sep 22, 2022
@estruyf estruyf mentioned this issue Sep 22, 2022
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Project: v8.1.0
Projects
None yet
Development

No branches or pull requests

2 participants