Trying to figure out how to add a text description to featherlight.js lightbox image gallery. Does anybody know or have any experience?
Here's an example of how the html is laid out:
<div class="mix digital" data-myorder="12" style="display: inline-block;">
<a class="gallery2" href="gallery_images/design/woodcut.jpg">
<div class="thumbnail" style="background-image:url(gallery_images/design/woodcut_th.jpg);"></div></a>
</div>
<div class="mix digital" data-myorder="11" style="display: inline-block;">
<a class="gallery2" href="gallery_images/design/script.jpg">
<div class="thumbnail" style="background-image:url(gallery_images/design/script_th.jpg);"></div></a>
</div>
...plus many more images
I would just like to be able to add a little bit of text as a description of the images in the light box when they open up and I can't find this in the documentation.
If not, does anybody know of a good/light lightbox that could achieve this?
Trying to figure out how to add a text description to featherlight.js lightbox image gallery. Does anybody know or have any experience?
Here's an example of how the html is laid out:
<div class="mix digital" data-myorder="12" style="display: inline-block;">
<a class="gallery2" href="gallery_images/design/woodcut.jpg">
<div class="thumbnail" style="background-image:url(gallery_images/design/woodcut_th.jpg);"></div></a>
</div>
<div class="mix digital" data-myorder="11" style="display: inline-block;">
<a class="gallery2" href="gallery_images/design/script.jpg">
<div class="thumbnail" style="background-image:url(gallery_images/design/script_th.jpg);"></div></a>
</div>
...plus many more images
I would just like to be able to add a little bit of text as a description of the images in the light box when they open up and I can't find this in the documentation.
If not, does anybody know of a good/light lightbox that could achieve this?
Share Improve this question edited Sep 21, 2015 at 21:44 Simon Arnold 16.2k8 gold badges68 silver badges88 bronze badges asked Jan 19, 2015 at 4:35 nolaw09nolaw09 511 silver badge2 bronze badges1 Answer
Reset to default 9featherlight
aims to be light and doesn't have a builtin option for this, but it's easy to do with the afterContent
callback.
For example, imagine that your text is in the 'alt'
attribute of the a
tag, you could specify:
afterContent: function() {
// Add a div for the legend if needed:
this.$legend = this.$legend || $('<div class="legend"/>').insertAfter(this.$content);
// Set the content:
this.$legend.text(this.$currentTarget.attr('alt'));
}
Here's a working example.