kuba2 Posted November 30, 2015 Posted November 30, 2015 Hello there Can anybody tell me how I can add captions to the images in my photo gallery using fancybox? I thought I could use the description field, but can't figure that one out. Like this: title='{$thumbnail->description}' My code for the image gallery: <?php foreach($page->bildergalerie as $image) { $thumbnail = $image->size(180,180); echo "<a href='{$image->url}' class='fancybox' rel='group'><img src='{$thumbnail->url}' alt='{$thumbnail->description}' ></a>"; } ?> Thanks a lot Kuba
Martijn Geerts Posted November 30, 2015 Posted November 30, 2015 This is more of a Fancybox question than a ProcessWire one. But something along the below lines might work. Be aware that it is not tested. $(document).ready(function () { $(".fancybox").fancybox({ helpers : { title: { type: 'inside'} }, afterLoad: function () { this.title = $(this.element).find('img').attr('alt'); } }); }); 2
kuba2 Posted November 30, 2015 Author Posted November 30, 2015 Thank you for the response I got it working! Put this in the <a> tag title='{$thumbnail->description}' <?php foreach($page->bildergalerie as $image) { $thumbnail = $image->size(180,180); echo "<a href='{$image->url}' class='fancybox' rel='group' title='{$thumbnail->description}'><img src='{$thumbnail->url}' alt='{$thumbnail->description}' ></a>"; } ?>
Marty Walker Posted November 30, 2015 Posted November 30, 2015 You might be better off using something like Lightcase (http://cornel.bopp-art.com/lightcase/) or Photoswipe (http://photoswipe.com/). Both are easier to configure when it comes to captions. 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now