message-event-channel connection
message-event-channel connection
This method will trigger opening the media browser. It returns a promise that will resolve to the chosen Image or Video Link.
Example of fetching media from DC
try {
// open browser and waits for media browser
// returns object that should be saved to the model
const video = await sdk.mediaLink.get()
} catch (e) {
// no media returned
}
This method will trigger an image browser. It returns a promise that will resolve to the chosen Image Link.
Example of fetching an image from DC
try {
// open browser and waits for image
// returns object that should be saved to the model
const image = await sdk.mediaLink.getImage()
} catch (e) {
// no image returned
}
Example of displaying a image in your custom control
import { init } from 'dc-extensions-sdk';
import { Image: ImageBuilder } from 'dc-delivery-sdk-js';
async function start() {
const sdk = await init();
const img = document.querySelector('img');
const button = document.querySelector('button')
function onClick() {
sdk.mediaLink
.getImage()
.then(image => {
setImage(image)
})
.catch(err => console.log('not selected'));
}
function setImage(image) {
img.src = (
new ImageBuilder(image, { stagingEnvironment: sdk.stagingEnvironment })
.url()
.build()
)
}
button.onclick = onClick;
}
start()
This method will trigger an image browser. It returns a promise that will resolve to the chosen Image Links.
Example of fetching an image from DC
try {
// open browser and waits for image
// returns object that should be saved to the model
const images = await sdk.mediaLink.getImages({ max: 10 })
} catch (e) {
// no image returned
}
This method will trigger opening the media overlay. It returns a promise that will resolve to the chosen Image and Video Links.
Example of fetching an media from DC
try {
// open browser and waits for media selection
// returns object that should be saved to the model
const media = await sdk.mediaLink.getMultiple({ max: 10 })
} catch (e) {
// no media returned
}
This method will trigger a video browser. It returns a promise that will resolve to the chosen Video Link.
Example of fetching an video from DC
try {
// open browser and waits for video
// returns object that should be saved to the model
const video = await sdk.mediaLink.getVideo()
} catch (e) {
// no video returned
}
This method will trigger a video browser. It returns a promise that will resolve to the chosen Video Links.
Example of fetching an video from DC
try {
// open browser and waits for video
// returns object that should be saved to the model
const videos = await sdk.mediaLink.getVideos()
} catch (e) {
// no video returned
}
Generated using TypeDoc
Media Link - Use to open the media browser.