Media

Media container

Setup

There are 2 ways to initialise the component.

Automatic

Add data-ecl-auto-init="MediaContainer" attribute to component's markup:

<div
  class="ecl-media-container"
  data-ecl-media-container
  data-ecl-auto-init="MediaContainer"
>
  ...
</div>

Use the ECL library's autoInit() (ECL.autoInit()) when your page is ready or other custom event you want to hook onto.

Manual

Get target element, create an instance and invoke init().

Given you have 1 element with an attribute data-ecl-media-container on the page:

var elt = document.querySelector('[data-ecl-media-container]');
var mediaContainer = new ECL.MediaContainer(elt);
mediaContainer.init();

Retrieve an existing instance

If an existing instance needs to be updated, it can be retrieved this way:

var elt = document.querySelector('[data-ecl-media-container]');
var instance = ECL.components.get(elt);

API