Jump to content

Adding Images to coverpage module body

Recommended Posts

I want to add an image in the body of a coverpage, however only code can be placed in the Advanced settings of these pages and cannot be placed in the text box. All the code injections I use preload my image and then it disappears when the cover page loads. This is what I've used so far for the insertion of the image. What I want to do is to for an image to be placed between 2 paragraphs in the text body.

<div id="custom-container">
  <p>First paragraph of text.</p>
  <img id="custom-image" src="URL_TO_YOUR_IMAGE.jpg" alt="Your Image Alt Text">
  <p>Second paragraph of text.</p>

  // Get references to the container and the image
  var container = document.getElementById("custom-container");
  var image = document.getElementById("custom-image");

  // Create a new paragraph element for text
  var newParagraph = document.createElement("p");
  newParagraph.textContent = "This is a dynamically added paragraph.";

  // Insert the new paragraph after the image
  container.insertBefore(newParagraph, image.nextSibling);


Edited by Uzfren
Link to comment
  • Replies 1
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • 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.