Jump to content

NewClassicalDesign

Circle Member
  • Posts

    12
  • Joined

  • Last visited

Community Answers

  1. NewClassicalDesign's post in author bio avatar on summary block page was marked as the answer   
    ended up answering my own question. For what its worth I had to add the script in a separate code block in its own <div> since it wasn't letting me append an element in the summary block itself. Then I styled the block so it appeared beneath the author. Also I realized document.getElementsByClassNames produces an array-like object instead of an element so I had to iterate over it to search for the text.
    Here is the updated script I used: 
    <div id="author-feature" style="margin-top:-100px;"> </div> <script> var img = document.createElement("img"); let author = document.getElementsByClassName('summary-metadata-item--author'); for (i = 0; i < author.length; i++) { if(author[i].innerHTML.includes('Bryan Specht')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce73e9cfee41177b9e75/1635307123576/BRYAN_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Rick Shaughnessy')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce8f24061f5729aaf1ad/1635307151493/RICK_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Charlie Witkowski')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce766084256498dff499/1635307126503/CHARLIE_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Andrea Zimmerman')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce6c25addd661972eb89/1635307116533/ANDREA_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Jaclyn Johnston')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce8562c22f532e4a39d8/1635307141583/JACLYN_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Tricia Ewald')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce95b52a8b6c21764ae0/1635307158005/TRICIA_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else if(author[i].innerHTML.includes('Daniel Welch')){ img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178ce7b72d1556873b61489/1635307131576/DANIEL_1_b_w_square.png"; img.setAttribute("style", "width:100px; border-radius:50%;"); var block = document.getElementById("author-feature") block.appendChild(img); } else { img.src = "https://static1.squarespace.com/static/614a0273f17c0447042d5f78/t/6178d2e414c5322fe396ec28/1635308260460/salient_favicon.png"; var block = document.getElementById("author-feature") block.appendChild(img); } } </script>  
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.