Jump to content

Adding captions using fancybox


kuba2
 Share

Recommended Posts

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

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');
        }
    });
});
  • Like 2
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...