I am using Galleria (classic) and I can't get it to add custom description on images. Otherwise the gallery works fine, only I see the img file name in caption.
I'm trying to use the dataConfig function - http://galleria.io/docs/options/dataConfig/. I am not that good at JavaScript so I can't really see what I'm doing wrong.
My code:
<div id="galleria">
<% for image in @trip.images %>
<%= link_to image_tag(image.image.url(:thumb)), image.image.url(:large) %>
<span class="desc"> <%= image.title %> </span>
<% end %>
</div>
<script>
Galleria.run('#galleria');
Galleria.configure({
minScaleRatio: 1.5,
maxScaleRatio: 3,
dataConfig: function(img) { return { description: $(img).next('.desc').html() }; }
});
</script>
</div>
Can You please help ? Thank you!
Update: generated HTML code
<div id="galleria">
<a href="http://s3.amazonaws.com/Thrill/images/439/large/14d8868ac166ce1.54701969.JPG?1326357617"><img alt="14d8868ac166ce1.54701969" src="http://s3.amazonaws.com/Thrill/images/439/thumb/14d8868ac166ce1.54701969.JPG?1326357617" /></a>
<span class="desc" style=""> aaaaaaaaaaaaaaa </span>
<a href="http://s3.amazonaws.com/Thrill/images/440/large/14c77a671ced5e4.22721576.JPG?1326357627"><img alt="14c77a671ced5e4.22721576" src="http://s3.amazonaws.com/Thrill/images/440/thumb/14c77a671ced5e4.22721576.JPG?1326357627" /></a>
<span class="desc" style=""> bbbbbbbbbbbbbbbbbbbbbbbbb </span>
</div>
It should work: http://jsfiddle.net/7g7am/
Galleria.run('#galleria', {
dataConfig: function(img) {
return {
description: $(img).parent().next('.desc').html()
};
}
});