Jump to content

Hi, is it possible to put lightbox to images inside of an accordion?

Recommended Posts

Posted

Hi, Would be possible to make images as lightbox (so when someone clicks on them they show up as a full screen) that I added through an URL method and this query: <script>
document.querySelectorAll('.accordion-item__description').forEach((item) => {
    item.querySelectorAll('a').forEach((link) => {
        if(link.querySelector('strong')) {
            const imgSrc = link.href;
            const img = document.createElement('img');
            img.src = imgSrc;
            img.alt = link.querySelector('strong').innerText;
            img.style.maxWidth = '100%';
            link.replaceWith(img);
        }    
    })    
});
</script>

 

Ste Url: https://oarfish-grapefruit-g8wm.squarespace.com/

Pass: ricestring

 

Thanks in advance

  • Replies 3
  • Views 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

Posted
6 hours ago, tuanphan said:

Hi,

Which images are you referring to? I don't see Accordion on homepage

HI the accordion is in the MENU page, Every iTem has an image. I would like to make a lightbox for every Image

 

Posted
On 1/10/2024 at 10:10 AM, lletleads said:

HI the accordion is in the MENU page, Every iTem has an image. I would like to make a lightbox for every Image

 

So It's like an online menu where people can click on the item and can show the image full screen

Would be awesome

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.