Jump to content

Add featured image to paywall blog preview

Recommended Posts

Hello!

I am creating a paywall for a blog on my squarespace 7.1 site and have the business plan.

When someone see's the preview of the blog, they see the Title, meta content, and excerpt. Is there a way to also include the featured image in the paywalled blogs preview content?

I have already got the featured image to show at the top of blogs using the following in "blog item code injection":

 

<style>
  div.blog-item-image-wrapper { margin-bottom:12px; }
  img.blog-item-image { width:100%; }
</style>
<script>
  const i = document.querySelector('meta[itemprop="image"]');
  const u = !!i ? i.getAttribute('content') : '';
  if (u) {
    const c1 = document.querySelector('.blog-item-inner-wrapper');
    const c2 = document.querySelector('.blog-item-top-wrapper');
    const ed = document.createElement('div');
    ed.setAttribute('class','blog-item-image-wrapper');
    const ei = document.createElement('img');
    ei.setAttribute('class','blog-item-image');
    ei.setAttribute('src',u);
    ed.appendChild(ei);
    c1.insertBefore(ed,c2);
  }
</script> 

 

 

Thank you

blog preview.png

behind paywall.png

Link to comment
  • Replies 3
  • Views 906
  • Created
  • Last Reply

Top Posters In This Topic

On 3/19/2024 at 8:18 PM, IdTaylor said:

Amazing thank you! I've removed that code and added an image block to the top of the post.

Please could you share the code to move this block above the title and date? Thank you so much

I forgot ask blog url. Can you share it?

Or you can follow this guide, I just wrote

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

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.