Squarespace: Clickthrough URLs on Wexley and Wells

If you’re using the Wells or Wexley template on Squarespace, you’ve probably realized by now that the GALLERY pages let you insert a clickthrough URL for each image, but those don’t actually function as clicking on an image will just open the image in full-screen mode. Here’s how you can have clickthrough URL’s working on image galleries in the Wells and Wexley template.

Click the GEAR icon on the gallery page

Enter this code under ADVANCED > PAGE HEADER CODE INJECTION.

<script>
   var currentPageBaseURL=window.location.href.split("?")[0];
      Y.on("domready",function(e){
         Y.io(currentPageBaseURL+"?page=1&format=json-pretty", {
            on:{success: jsonLoaded}
         });
         function jsonLoaded(err,data){
            var jsonResponse = Y.JSON.parse(data.responseText);
            var items=jsonResponse.items
            Y.all("#thumbnails .thumb, #slideshow .slide").each(function(e){
               var thumbId=this.getAttribute("data-slide-id");
               for(var i=0;i<items.length;i++){
                  if(thumbId==items[i].id && items[i].clickthroughUrl){
                     this.setAttribute("data-clickthrough-url",items[i].clickthroughUrl).on("click",function(e){
                        e.preventDefault();
                        e.stopPropagation();
                        window.location = this.getAttribute("data-clickthrough-url");
                     })
                  }
               }
          })
      }
   });
</script>
MORE VIDEO TUTORIALS

Want more help? We have tons of YouTube tutorials on customizing your Squarespace website. Subscribe to our channel so you will know when a new tutorial is out.

Vigasan Gunasegaran About the author
vigasan@live.com

I've been working on Squarespace and WordPress websites for quite some time now. I enjoy how easy it is for clients to make updates to their own websites while using a CMS system. Outside of website design, I love good food, Netflix, and video games.

Comments:
  • Hi this does not work for multiple gallery images. Only the first image within a gallery page – please advise. Thanks

    February 18, 2019 at 4:51 PM

Leave a Reply