mgroeteke Posted August 28, 2023 Share Posted August 28, 2023 please have a look at the attached screenshot, how could i make the image clickable and linked to the corresponding blog entry? a general solution working for all the site would be preferable. thank you so much for helping out. markus markus/architectureshooting web site: http://architectureshooting.com Link to comment
Solution paul2009 Posted August 31, 2023 Solution Share Posted August 31, 2023 On 8/28/2023 at 2:42 PM, architectureshooting said: how could i make the image clickable and linked to the corresponding blog entry? Your screenshot shows a Blog List Page and so the main image of a post isn't linked. If you're on a Business Plan or higher, some JavaScript can be written to pull the URL from each post title and then wrap a duplicate link around the main-image of the post. A simplified version (to add to the Footer Code Injection) might look something like this: <script> const articles = document.querySelectorAll('article'); articles.forEach(article => { const h1Link = article.querySelector('header h1.entry-title a'); const mainImageDiv = article.querySelector('.main-image'); if (h1Link && mainImageDiv) { const url = h1Link.href; const link = document.createElement('a'); link.href = url; mainImageDiv.parentNode.insertBefore(link, mainImageDiv); link.appendChild(mainImageDiv); } }); </script> This script will find the blog posts (articles) on the page and then iterate through each article to grab the URL being used by the h1 link in each article's header. It will then wrap the main-image div within each article with a duplicate link using the same URL. Like all code on the forum, this is just an example. It hasn't been extensively tested or designed to apply to lazy-loaded posts that might load later. In this recording you'll see that each image is now linked, as shown by the link description (bottom-right) that appears when the pointer hovers over one of the images: Did this help? Please give feedback by clicking an icon below ⬇️ Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional. Would you like your customers to be able to mark their favourite products in your Squarespace store? Link to comment
mgroeteke Posted September 9, 2023 Author Share Posted September 9, 2023 paul, sorry to reply late - was on a vacation. thank you so much, this was really helpful and it is working well with almost all of my blog post entries! paul2009 1 markus/architectureshooting web site: http://architectureshooting.com Link to comment
paul2009 Posted September 9, 2023 Share Posted September 9, 2023 (edited) 26 minutes ago, architectureshooting said: thank you so much, this was really helpful You're welcome. 26 minutes ago, architectureshooting said: it is working well with almost all of my blog post entries The solution won't modify blog posts that have a Promoted Block. Promoted Blocks are a special feature on older templates like Wells, where they treat the first block in a blog post differently. In this case forcing the Promoted Block to appear above the title. If you don't like how promoted blocks look on your site, you can disable them in Website > Design > Template Settings: Alternatively, if you want to decide on a post-by-post basis, you can reformat an individual post to avoid the first block being promoted. For example, if the first block in the post is an Image Block, you could add a single line Text Block just above it. I hope this helps to explain 🙂 Did this help? Please give feedback by clicking an icon below ⬇️ Edited September 9, 2023 by paul2009 Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional. Would you like your customers to be able to mark their favourite products in your Squarespace store? Link to comment
kellyhutsbydesigns Posted September 9 Share Posted September 9 @paul2009 Could you edit this to apply to summary blocks please? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment