Jump to content

How to add lightbox captions in masonry gallery?

Recommended Posts

Site URL: https://www.jurajsimkovic.com/projects/slovak-national-theatre

Hi, as the title says, I would like to add specific captions to specific images in my gallery and, this is important, I want them to only appear in the lightbox view. I don't want them to appear under the images when viewed casually on the site, without lightbox.

Most of them are masonry grid-galleries, one of them is a simple grid-gallery.

I have just paid for the personal plan and would like to avoid upgrading and paying for the higher tier business plan.

The picture attached to this post should clarify the look of the captions.

Thank you in advance.

Juraj

Screenshot 2021-10-26 at 13.18.09.png

Link to comment
  • Replies 14
  • Views 1.7k
  • Created
  • Last Reply

Top Posters In This Topic

2 hours ago, Jurajsimkovic said:

Site URL: https://www.jurajsimkovic.com/projects/slovak-national-theatre

Hi, as the title says, I would like to add specific captions to specific images in my gallery and, this is important, I want them to only appear in the lightbox view. I don't want them to appear under the images when viewed casually on the site, without lightbox.

Most of them are masonry grid-galleries, one of them is a simple grid-gallery.

I have just paid for the personal plan and would like to avoid upgrading and paying for the higher tier business plan.

The picture attached to this post should clarify the look of the captions.

Thank you in advance.

Juraj

Screenshot 2021-10-26 at 13.18.09.png

You can use the unique id of the image in lightbox to add the caption using css, but it is a painful process and hard to maintain once you got many images on the site

image.thumb.png.c1d26bfe10bce8f24b19db726fd7e400.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 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

Could you please elaborate on this process, maybe provide something of a how to guide? I am not proficient with CSS editing - I can't write my own code.

I have to note again, I have the personal plan and would like to avoid upgrading to a more expensive one.

Edited by Jurajsimkovic
Link to comment
On 10/26/2021 at 9:32 PM, Jurajsimkovic said:

Could you please elaborate on this process, maybe provide something of a how to guide? I am not proficient with CSS editing - I can't write my own code.

I have to note again, I have the personal plan and would like to avoid upgrading to a more expensive one.

Hi.

Do you still need help?

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
  • 9 months later...
On 8/10/2022 at 9:08 AM, dangarza said:

Hi @tuapan

I have the same issue as Jurajsimkovic, I want captions to display on lightbox from my masonry grid which already has your code for hover over captions (thanks!!!)

I need the captions to look like the image attached. Any tips? 

Thanks so much for your help!

D

 

491171825_Screenshot2021-10-26at13_18_09.thumb.png.daa90ed2bf8cf3e00390beddea326959.png

What is your site url? We can help easier

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
On 8/16/2022 at 10:44 PM, dangarza said:

@tuanphanAs you can see there´s capttions on hover over in masonry grid, but not when we go to lightbox, that´s what Im missing

 

thanks so much

image.png

Screen Shot 2022-08-16 at 11.42.14 AM.png

Your site is private. Can you setup an access password & share url again?

https://cobalt-strawberry-9gtg.squarespace.com/?noredirect

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
On 8/18/2022 at 11:39 PM, dangarza said:

Hi  @tuanphan I made it public 🙂 here's the link

https://cobalt-strawberry-9gtg.squarespace.com

galleries in exhibitions have the style I talked about, hope this guves you a better idea

thanks!

Can you enable Gallery Section Caption & add some demo text? We will test some code to achieve this

https://cobalt-strawberry-9gtg.squarespace.com/exhibitions-1/nf

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
On 8/22/2022 at 11:50 PM, dangarza said:

@tuanphan done! thanks so much!

Try adding this to Code Injection > Footer

<script>
document.addEventListener("DOMContentLoaded", function() {

  function render(checked, index) {
    
    (function(p, show) {
      var map;
      var values;
      var messageValue;
      var messages;
      var name;
      var type;
      var k;
      map = document.querySelectorAll(p ? p : 'section.gallery-section,\x20.gallery-lightbox');
      name = map.length;
      for (; name--;) {
        values = map[name].querySelectorAll(show ? show : '[class*=\x27-item\x27]:not([class*=\x27item-\x27])');
        type = values.length;
        for (; type--;) {
          messageValue = values[type].getElementsByTagName('img')[0]['alt']['trim']();
          if (messageValue && messageValue.includes("png") == false && messageValue.includes("jpg") == false) {
            messages = document.createElement('div');
            messages.className = 'gallery-item-description';
            messages.textContent = messageValue;
            values[type].appendChild(messages);
          }
        }
      }
    })(checked, index);
  }
  render();
});
</script>

 

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
  • 10 months later...
On 8/24/2022 at 10:59 AM, tuanphan said:

Try adding this to Code Injection > Footer

<script>
document.addEventListener("DOMContentLoaded", function() {

  function render(checked, index) {
    
    (function(p, show) {
      var map;
      var values;
      var messageValue;
      var messages;
      var name;
      var type;
      var k;
      map = document.querySelectorAll(p ? p : 'section.gallery-section,\x20.gallery-lightbox');
      name = map.length;
      for (; name--;) {
        values = map[name].querySelectorAll(show ? show : '[class*=\x27-item\x27]:not([class*=\x27item-\x27])');
        type = values.length;
        for (; type--;) {
          messageValue = values[type].getElementsByTagName('img')[0]['alt']['trim']();
          if (messageValue && messageValue.includes("png") == false && messageValue.includes("jpg") == false) {
            messages = document.createElement('div');
            messages.className = 'gallery-item-description';
            messages.textContent = messageValue;
            values[type].appendChild(messages);
          }
        }
      }
    })(checked, index);
  }
  render();
});
</script>

 

This code seems to almost work. Just now I have caption twice in the lightbox and in the gallery view. Any idea what causes duplication of the caption text?

It adds .gallery-item-description but it does not hide the out-of-the-box .gallery-caption so the text is shown twice. How to fix it and only show text once?

Edited by acheam
Link to comment
On 7/11/2023 at 2:20 AM, acheam said:

This code seems to almost work. Just now I have caption twice in the lightbox and in the gallery view. Any idea what causes duplication of the caption text?

It adds .gallery-item-description but it does not hide the out-of-the-box .gallery-caption so the text is shown twice. How to fix it and only show text once?

Can you share link to page where you use masonry?

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.