Galleria jQuery plugin customization question -
i'm trying customize galleria jquery plugin allow rich captions using dataconfig function detailed here. basic code gallery follows:
<div id="galleria"> <ul> <li> <img src="myimg.jpg"> <h2>lorem ipsum title</h2> <div class="desc">you can add <strong>strong</strong> tags or other html caption</div> </li> </ul> </div> <script> $('#galleria').galleria({ dataconfig: function(img) { return { title: $(img).next('h2').html(), // tell galleria use h2 title description: $(img).siblings(.desc).html() // tell galleria grab content .desc div caption }; } }); </script>
the issue i'm having if wrap img tag in anchor, follows--
<li> <a href="full-size.jpg"><img src="myimg.jpg"></a> <h2>lorem ipsum title</h2> <div class="desc">you can add <strong>strong</strong> tags or other html caption</div> </li>
--to allow graceful degradation if js disabled-- "title" , "description" references in dataconfig function no longer work, realize jquery looking h2 , "desc" class following img tag, , placing within anchor seems break reference it's entered-- i.e. via (img).next , (img).siblings. question therefore how can change these title , description jquery references work image resides within anchor tag. realize can place anchor around entire block-- ie. img, h2 , "desc" div-- believe technically allowed in html5 spec, , continue work entered, i'd rather wrap img.
i guess more of basic jquery question else; assistance here.
assuming have 1 li per 'item':
$('#galleria').galleria({ dataconfig: function(img) { var block = $(img).closest('li'); // find parent return { title: block.children('h2').html(), description: block.children('.desc').html() }; } });
Comments
Post a Comment