Jump to content

Featured Image/Thumbnail Code Injection

Recommended Posts

If you use a Business Plan or higher, you can add an Image Block on top of post content. Then let me know. We will give the code to move it to top of post title.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 3 weeks later...
11 hours ago, nickmohler said:

@tuanphan - yes the site is through a business plan. What are the next steps? Thanks

Untitled (3).jpg

Add this snippet into Advanced-Code injection- Footer

<style>
.BlogItem-image { height: 0; padding-bottom: 56%; position: relative; overflow: hidden; } .BlogItem-image img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }</style>
<script>
var blogBody = document.querySelector('.Main--blog-item [data-layout-label="Post Body"]')
if (blogBody) {
    var featuredImage = document.querySelector('meta[property="og:image"]').getAttribute("content");
    var tpl = `<div class="BlogItem-image"><img src="${featuredImage}"/></div>`;
    blogBody.insertAdjacentHTML('afterbegin', tpl);
}
</script>

image.thumb.png.ce5211fa420f3646c3d539b7dce7a182.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date format)
💫 Animated Buttons (Referral URL)
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
  • 8 months later...
On 3/11/2022 at 3:54 AM, noahawaii said:

This doesn't seem to work with the vester template. I don't have a live site right now to show because it's being developed. Is there something that needs to be changed in it?

You can setup site access password then share url.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
On 6/27/2021 at 1:14 AM, bangank36 said:

Add this snippet into Advanced-Code injection- Footer

<style>
.BlogItem-image { height: 0; padding-bottom: 56%; position: relative; overflow: hidden; } .BlogItem-image img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }</style>
<script>
var blogBody = document.querySelector('.Main--blog-item [data-layout-label="Post Body"]')
if (blogBody) {
    var featuredImage = document.querySelector('meta[property="og:image"]').getAttribute("content");
    var tpl = `<div class="BlogItem-image"><img src="${featuredImage}"/></div>`;
    blogBody.insertAdjacentHTML('afterbegin', tpl);
}
</script>

image.thumb.png.ce5211fa420f3646c3d539b7dce7a182.png

Is this page a blog post? I'm trying to figure out where squarespace pulls each blog's featured image from outside of the specific url for an image. I wasn't able to get it when the source was ${featuredImage} as you have above. Is it different for each website or how did you come up with that source?

Link to comment
On 3/10/2022 at 12:54 PM, noahawaii said:

This doesn't seem to work with the vester template.

The original code was designed for v7.0 Brine template family.

Most likely it would need to be updated to work with v7.1, if it can be done.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

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.