Media property definition
This API is under development. Do not rely on it. It may change or be removed in future versions.
Fieds
The media definition property template can be used to add a custom property of media type. When defining a media property, the following fields can be used:
type
This field is mandatory for media.
Should always be defined as string for media items
label
Used for defining the label of the item.
component
Used for defining how the property is visualized in the property panel. Used to override the default component that comes with the type setting.
This field is mandatory for a link property and should always be "media".
ref
Name or ID used to reference a property.
layoutRef
Name or ID used to reference the layout.
Example
Defining a custom media property
Defining a custom property of media type can look like below.
Example:
define( [
],
function ( ) {
return {
definition : {
type : "items",
component : "accordion",
items: {
settings: {
uses: "settings",
items: {
MyMedia: {
label:"My media",
component: "media",
ref: "myMedia",
layoutRef: "myMedia",
type: "string"
}
}
}
}
},
paint: function ($element, layout) {
//add your rendering code here
$element.css("background-size","cover");
$element.css("background","url("+layout.myMedia+") no-repeat left top fixed");
$element.html( "props-media "+layout.myMedia );
}
};
} );