This is what I have done…
{{#featuredImage}}
{{#if url}}
<script>
var heroArray = document.getElementsByClassName("hero-container");
for(var i = 0; i < heroArray.length; i++) {
heroArray.style.backgroundImage = "url('media/files/images/pexels-emmylou-736508-1366.webp')";
}
</script>
{{/if}}
{{/featuredImage}}
The java is not elegant, but it works.
What I am struggling with now is…
{{#featuredImage}}
{{#if url}}
… for some reason this is not picking up the featured image on my test post. This works in another template inside of a…
{{#each posts}}
… but it does not seem to pick up just under the body tag where I expected it to pick up the featured image of the test post.
I assume I am doing something wrong. I am at a loss as to what it is at this point.
Cheers!!