kuba2 Posted November 30, 2015 Share 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 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 30, 2015 Share 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 Link to comment Share on other sites More sharing options...
kuba2 Posted November 30, 2015 Author Share 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>"; } ?> Link to comment Share on other sites More sharing options...
Marty Walker Posted November 30, 2015 Share 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 Link to comment Share on other sites More sharing options...
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