Skip to main content Skip to complementary content

Media property definition

Warning noteEXPERIMENTAL.

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

Information noteThe media effect is achieved by defining the component field to "media", see below.

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.

Information noteAdding media from the In app media library is not supported in this release.

Example

Defining a custom media property

Defining a custom property of media type can look like below.

Example:  

Information noteCustomization of properties always start with items:.
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 );
		}
	};

} );

This is what it looks like in the property panel

An interface titled "media properties" with the subtitle "Appearance". Appearance contains two hide and show buttons called "General" and "My media". Under the "My media" button, there is a blank image with the caption "My media" above it.

This is what it may look like after selecting to display an image

An interface titled "media properties" with the subtitle "Appearance". Under "Appearance", there are two hide and show buttons called "General" and "My media". Under "My media" there is a graphic of two overlapping circles. One circle is yellow and bigger than the smaller green circle that it is overlapping with. The image is captioned "My media".

And this is what the visualization itself may look like after selecting to display an image

A bordered image with draggable resize buttons on each corner. There are also draggable resize buttons on the center of each of the border's sides. Inside there is a title "media properties". There is text below the title contains a file path to a PNG image.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!