top of page

Programmatic


Another way to include an image on the page is through the tag’s API.

const d8sApi = initDimensions({ ... });

d8sApi.addImage(document.getElementById("my-image"), { 
    id: "my-shoe", 
    preset: "shoes",
    name: "front"
});

d8sApi.addVideo(...); //add video

d8sApi.addThreeD(...); //add 3d viewer

The add*() functions can be used to add additional assets to the page explicitly.

The tag also exposes events that can be accessed through a handler:

const d8sApi = initDimensions({ ... });

const unregister = d8sApi.on((event, ...args) => {
  console.log(
    `######### DIMENSIONS EVENT LISTENER CALLED - event: ${event}`,
    ...args
  );
});

This will log events from the tag about the viewers load and interaction.

Example: ​######### DIMENSIONS EVENT LISTENER CALLED - event: tag-image-load-start

Related Posts

See All

Set Website Integration

Learn how to add a code snippet to easily embed Dimensions assets using HTML and/or Javascript code. The dimensions tag is a JS snippet...

HTML Tag Attributes

The tag searches for specific data attributes in your page’s HTML. 🖼️ Images Include an image in your website like this: <div...

Global Viewer Configurations

To globally set Viewer-related properties, you can add the following config to the Dimensions tag init: const d8sApi = initDimensions({...

bottom of page