statamic / ideas

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

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

Open daun opened 4 months ago

daun commented 4 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 4 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 4 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 đŸ¤