Hi,
You can customize the image gallery/slider modules using HubL:
{% gallery "crm_gallery" label="CRM Gallery", export_to_template_context=True %}
The “export_to_template_context” part releases all of the data for the module into the template for you to play with. The data that is available for the gallery module is:
"slides": [{
"img_src": "",
"alt_text": "",
"href": "",
"link_url": "",
"open_in_new_tab": true,
"show_caption": false,
"caption": ""
}]
You set this data up by adding images to the gallery on the editing page, so you would go to the page editor and add an image, the alt text for the image, a link if needed, and a caption.
Then you can fully customize the gallerys markup by looping through it:
{% gallery "crm_gallery" label="CRM Gallery", export_to_template_context=True %}
{% for item in widget_data.crm_gallery.slides %}
<img src="{{ item.img_src }}" alt="{{ item.alt_text }}">
{% endfor %}
I create the gallery widget, exporting the data to the template. I then make a for loop that says for each slide in the image gallery I want to output this image tag.
The code inside the for loop can be as simple or complex as you can make it. you can use divs or other wrappers, paragraphs, ids, classes, you name it. It will print whatever you put here per slide, so if you add 100 images to the gallery it will out put the code 100 times on the page.
You can use any of your own js to do what ever you want with the images because you have full control of how the data is output.
To use the data just use
{{ item.img_src }}
{{ item.alt_text }}
{{ item.caption }}
{{ item.href }}
etc.
Where Item is the name given in the for loop:
{% for item in widget_data.crm_gallery.slides %}
You can change “item” to pretty much anything like “slide”, “image”, “block”. just make sure you change that identifier in the data tokens and your good to go.
crm_gallery is my system name for the gallery widget:
{% gallery "crm_gallery" label="CRM Gallery", export_to_template_context=True %}
so make sure that
{% for item in widget_data.crm_gallery.slides %}
reflects what ever you use as a system name for your widget.
You can place all of this inside a hubl module in the drag and drop editor or right in the page of a coded page.