For the complete documentation index, see llms.txt. This page is also available as Markdown.

Resource

Displays a resource dropwell that accepts all file types.

{
  "title": "Image",
  "id": "image",
  "resource": {}
}
{
  "groups": [{
    "title": "Content",
    "icon": "photo",
    "properties": [{
      "title": "Image",
      "id": "image",
      "resource": {}
    }]
  }]
}

Supported Options

The resource control accepts all file types by default. Use the following options to restrict it.

Key
Type
Notes

accepts

string

HTML <input accept>-style comma-separated list restricting which file types can be assigned.

excludes

string

Same token grammar as accepts, but subtracts matching types.

An empty or omitted accepts accepts any file type.

accepts

accepts uses the same token grammar as the HTML <input accept> attribute:

Token
Matches
Example

.ext

A file extension

.svg

type/*

A MIME major type

image/*

type/subtype

An exact MIME type

video/mp4

Combine multiple tokens with commas, e.g. ".png,.jpg".

{
  "title": "Icon",
  "id": "icon",
  "resource": {
    "accepts": ".svg"
  }
}

excludes

excludes uses the same token grammar and subtracts specific types from accepts. A file matching any excludes token is rejected even if an accepts token matches. excludes without accepts means "accept everything except the excluded types".

Restrictions are enforced when a resource is assigned in the inspector, the canvas editor, and via the API, and also filter which drop targets accept a dragged file.

The legacy "types": ["svg"] array shorthand is still supported and folded in alongside accepts, but new components should use accepts.

Using Resources in Templates

Resource Properties

When you define a resource control, you can access its properties in your template:

Property
Description

{{resource.image}}

The URL/path to the image

{{resource.path}}

The file path (use for non-image files like video, PDF)

{{resource.width}}

Original width in pixels (images only)

{{resource.height}}

Original height in pixels (images only)

{{resource.aspect}}

Aspect ratio, e.g. 16/9 (images only)

Displaying an Image

Displaying a Video

For non-image resources like video files, use the .path property:

Checking if a Resource Exists

Use a conditional to handle cases where no resource has been selected:

Resource Dropzones

You can enable drag-and-drop directly onto an element in the editor by adding the rwResourceDropZone attribute. The value should match the id of your resource control.

Complete Example

properties.json:

templates/index.html:

Last updated

Was this helpful?