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

[5.x] Conditional fields in asset blueprints #10588

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from

Conversation

daun
Copy link
Contributor

@daun daun commented Aug 7, 2024

Make native asset data (width, height, filename, etc) available as hidden fields inside the asset editor component.

This enables field conditions inside asset blueprints against native asset data, e.g. to show fields for some filetypes only.

Closes statamic/ideas#1136

Example use case

The example below will show an Autoplay toggle for all videos shorter than a minute:

fields:
  -
    handle: autoplay
    field:
      type: toggle
      display: Autoplay
      if:
        extension: mp4
        duration: '<= 60'

Required changes

  • Asset Resource class: Append mimetype and duration in Asset resource
  • Asset Editor component: Create hidden fields for asset data, merge asset data with blueprint field data

Notes

  • Hiding the fields in the blueprint also ensures their data isn't sent along when saving the asset
  • The mime type field is available as mimeType — should this be snake-cased to mime_type to match the yaml key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow access to underlying asset data in asset blueprint fields
1 participant