statamic / ideas

đŸ’¡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Allow access to underlying asset data in asset blueprint fields #1136

Closed daun closed 1 month ago

daun commented 9 months ago

It'd be great to get access to the underlying asset data in custom field conditions of asset blueprints. Currently, we only get access to the values of other fields in the same blueprint.

Example: only show an autoplay toggle in the asset blueprint if the path of the asset ends with .mp4 — this is currently not possible as the custom field conditions do not have access to width, height, path, etc.

fields:
  -
    handle: autoplay
    field:
      type: toggle
      display: Autoplay
      inline_label: Autoplay
      inline_label_when_true: Autoplay
      if:
        this: 'custom video'
jasonvarga commented 9 months ago

Not a great solution, but it could work for you for now: Each container can have its own blueprint, so you could consider having a container just for your videos, and then in that blueprint you can put the video-specific fields.

daun commented 9 months ago

@jasonvarga I've thought about that, but I prefer the user experience of having all media in a single asset container. But I can probably hide the video-specific options behind a Revealer. Or set a custom hidden is_video field in the AssetCreated event that I will have access to as it's part of the blueprint. So many options đŸ¤