dataConfig( [HTML element] )
type: Functionarguments: HTML element
This very useful function configures how the data should be extracted from the source. It should return an object that will blend in with the default extractions.
Use this option to control how your data should be interpreted. A common case is when you have HTML markup that you would like to implement as captions. This option can tell Galleria how to interpret your HTML code so it collects the right data.
The argument is a HTML element selected from the HTML source ( most often an Image element ). Use this to traverse the source and return the right data into Galleria.
If you are using other elements than Images as source, you can change the selector using the data_selector option.
Default extractions from the HTML element:
image: the
src
attribute OR parent<a>
tag’shref
attribute (if exists and links to an image)thumb: the
src
attributetitle: the
title
attributedescription: the
alt
attributelink: the
longdsesc
attribute
Example on how to alter the extraction logic:
<div class="galleria">
<img src="myimg.jpg" rel="John Doe">
<span class="desc">My picture</span>
</div>
<script>
Galleria.run('.galleria', {
dataConfig: function(img) {
// img is now the image element
// the function should return an object with the new data
return {
title: $(img).attr('rel'), // sets title to "John Doe"
description: $(img).next('.desc').html() // sets description to "My picture"
};
}
});
</script>