Jump to content

How to use filename as a title for images in Gallery Block in 7.1 in 2022 ? Please and thank you.

Recommended Posts

I am trying to get a gallery block in 7.1 to display the file name as the Title.

I have "show title" ticked in Design panel.

I have tried some scripts from the forum, but they dont seem to work with 7.1

As I have hundreds of images to upload, i dont want to manually type the "Titles" in when the title is correct is the file name I upload. 

Any help, most appreciated.

With thanks

Adrian

Link to comment
  • 1 year later...

Old topic, but incase anyone is still in need of a solution, here is how I do it with jQuery.

I apply the code per page as I only use it on specific gallery pages made for client previews.

 

<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>

<script>
    // Function to replace image-slide-title content with alt tag for images within sqs-gallery-container using jQuery
    $(document).ready(function() {
      $('.sqs-gallery-container img').each(function(index) {
        $('.image-slide-title').eq(index).html($(this).attr('alt').replace('.jpg', ''));
      });
    });
  </script> 

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.