Updating the "Hero Image" in a TVOS template

189 views Asked by At

I'm trying to dynamically update the hero image source, inside a TVOS productTemplate.

I'm able to do this for the description, for example:

function changeDescription(incomingString) {
    if (incomingString) {
        var theDescription = myDoc.getElementsByTagName("description").item(0);
        theDescription.innerHTML = incomingString;
    }
}

.. but it's not working for the src value for the hero image:

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        var theHeroSrc = theHero.getAttribute("src");
        theHeroSrc.value = incomingString;
        // theHeroSrc.innerHTML = incomingString;
    }
}

I've verified the path is correct; what else should I look at?

2

There are 2 answers

1
cem olcay On BEST ANSWER

try setAttribute

theHero.setAttribute('src', incomingString)
2
Rob M. On

Updating images should use the src attribute, not value:

function changeHeroImage(incomingString) {
    console.log("local path: " + incomingString)
    if (incomingString) {
        var theHero = myDoc.getElementsByTagName("heroImg").item(0);
        theHero.src = incomingString;
    }
}