Links
Comment on page

Set image widget URL property

This example explains how to set a composition's image widget URL property.

Functions covered

  • comp.findWidget()
  • widget.getPayload()
  • widget.setPayload()
Load this example composition to follow along in a real composition.

Composition structure

The example composition has one sub-composition called Lower, as you can see in the composition tree.
The Lower sub-composition
To see this sub-composition's widgets:
  1. 1.
    Open the composition script editor within the same example composition as above and select the Lower composition script.
  2. 2.
    In the composition navigator, select the Widget Explorer tab.
This composition contains three widgets, but for this quick start, you'll look at its image widget, which in the composition is called lowerLogo.
The sub-composition's widgets

Composition script

Now that you have located the composition's widgets, learn how to set the image widget URL property by reading the comments in the Lower composition script.
You can also copy and paste the composition script below into your own compositions.
Lower Script
(function() {
return {
init: function(comp, context) {
// get reference to the logo widget
const wiLowerLogo = comp.findWidget("lowerLogo")[0];
// log widget object to the console
console.log(wiLowerLogo);
// update the image URL
wiLowerLogo.setPayload({
"image": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
});
},
close: function(comp, context) {}
};
})();