Hello,
I am looking to make a photo gallery with lightbox for a client.
You can see the beginning here. hidden link
I have created a repeating field (image) and in a 'foreach' loop.
I have to create a buttonn 'next' and 'prev' to navigate from one image to another but I don't know how to handle that. Can you help me on this. Thank you.
There is de code of de 'foreach' loop:
[wpv-for-each field="wpcf-photo-event"]
<div class="column">
<a class="lightbox" href="#[types field='photo-event' output='raw' [/types]">
[types field='photo-event' title='%%TITLE%%' alt='%%ALT%%' size='thumbnail'][/types]
</a>
</div>
<div class="lightbox-target" id="[types field='photo-event' output='raw'][/types]">
[types field='photo-event' title='%%TITLE%%' alt='%%ALT%%' size='large'][/types]
<a class="lightbox-close" href="#"></a>
<a class="previous" href="#[types field='photo-event' output='raw' [/types]"><</a>
<a class="next" href="#[types field='photo-event' output='raw' [/types]">></a>
</div>
[/wpv-for-each]
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
Thank you for contacting our support forum.
Have you tried using our Toolset blocks plugin along with the Gutenburg editor?
Take a look here at an example
hidden link
Where you can click the different gallery images and they open in a lightbox.
This entire page was built using toolset blocks and gutenburg.
Please let me know if you want to try something like this.
Thanks,
Shane
Hi shane,
Thank you for your answer.
Is it possible to use toolset blocks in a custom post type?
Thanks a lot for your help.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
HI Olivier,
Yes it is is possible to do.
In the example it was being used on a custom post type.
Thanks,
Shane
Thanks Shane,
you speak of gutenberg but I can not use it with my theme, does it work without it ?
And with repeated fields inside custom post type ?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
Unfortunately not 🙁
The toolset blocks plugin provides additional features to the gutenburg editor.
So your theme would need to be compatible with the gutenburg editor. Yes it create a gallery with the repeatable fields. See Screenshot
Thanks,
Shane
The customer does not want to use gutenberg, so I can not use it, is there another track? I have the impression that it does not miss much to my code so that it works, just a button next and prev, the rest works already well.
Thank you
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
The main issue I see here is that your code here
<a class="previous" href="#[types field='photo-event' output='raw' [/types]"><</a>
<a class="next" href="#[types field='photo-event' output='raw' [/types]">></a>
</div>
Is getting the URL for the same exact instance of the current photo being displayed. You will need to get the urls for the next and previous post.
Is it a plugin that you are using for the lightbox? If so could you send me a link so that I can see how they manually construct their lightbox.
Thanks,
Shane
It's not a plugin, it's pure css.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
Normally what happens is that javascript is used by the lightbox plugins to get the previous urls of the items on the page.
In your case you will need to use Javascript to get the url of the previous image and next url images.
Something like this
hidden link
Some javascript will be required for you to get the correct items.
Thanks,
Shane
ok,
how does this translate with the use of a repeated field?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
On the frontend each image is self contained based on how you depict your html.
[wpv-for-each field="wpcf-photo-event"]
<div class="column">
<a class="lightbox" href="#[types field='photo-event' output='raw' [/types]">
[types field='photo-event' title='%%TITLE%%' alt='%%ALT%%' size='thumbnail'][/types]
</a>
</div>
<div class="lightbox-target" id="[types field='photo-event' output='raw'][/types]">
[types field='photo-event' title='%%TITLE%%' alt='%%ALT%%' size='large'][/types]
<a class="lightbox-close" href="#"></a>
<a class="previous" href="#[types field='photo-event' output='raw' [/types]"><</a>
<a class="next" href="#[types field='photo-event' output='raw' [/types]">></a>
</div>
[/wpv-for-each]
Is there a documentation for the css that you are using to do this ? Could you send me that documentation ?
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Olivier,
Rather than doing this manually because we will need to write special code for this.
I would recommend using this plugin below.
https://wordpress.org/plugins/fancybox-for-wordpress/#description
If you want my help with setting this up you're more than welcomed to provide me with access to the site but building out the JS code required to do the next and previous arrows is definitely out of the scope of what I can provide as support.
Thanks,
Shane