Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MediaLink

Index

Constructors

Properties

Methods

Constructors

constructor

  • new MediaLink(connection: ClientConnection): MediaLink
  • Media Link - Use to open the media browser.

    Parameters

    • connection: ClientConnection

      message-event-channel connection

    Returns MediaLink

Properties

Private connection

connection: ClientConnection

message-event-channel connection

Methods

getImage

  • 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()

    Returns Promise<MediaImageLink>

getImages

  • 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
    }

    Parameters

    • Default value __namedParameters: object = { max: null }
      • max: null | number

    Returns Promise<MediaImageLink[]>

getVideo

  • 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
    }

    Returns Promise<MediaVideoLink>

getVideos

  • 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
    }

    Parameters

    • Default value __namedParameters: object = { max: null }
      • max: null | number

    Returns Promise<MediaVideoLink[]>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc