Skip Navigation

[Resolved] Fancybox is not working

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am displaying multiple instances image field. When a user clicks on an image, it should open the full-size in a lightbox.

Solution:

You can setup the HTML link, like this:

https://toolset.com/forums/topic/fancybox-is-not-working/#post-1208065

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/functions/#image

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by lawrenceK 5 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1207198

I am trying to have product images open in a lightbox in a content template without success. Here is a link to the page: hidden link

I am using the following code:

{!{wpv-for-each field="wpcf-product-images" class="fancybox"}!}
{!{types field='product-images' alt='%%ALT%%' title='%%TITLE%%' width='150' class="fancybox" height='150' align='none' resize='crop' separator=', '}!}{!{/types}!}
{!{/wpv-for-each}!}

According to the plugin author I need to "[...] ask the Toolset support how to modify that code to make it include a link to each full size image version."

Can you please assist?

#1207366

Hello,

For the question:
how to modify that code to make it include a link to each full size image version.

You can get the full size of custom image field by using size="full" attribute in Types shortcode, for example:

{!{types field="product-images"  size="full"}!}{!{/types}!}

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
size: custom image size

#1207690

This has no effect.

Let me be clear: I am displaying thumbnail images on this page. When a user clicks on an image, it should open the full-size in a lightbox.

Here is my code:
{!{wpv-for-each field="wpcf-product-images" class="fancybox"}!}
{!{types field='product-images' alt='%%ALT%%' title='%%TITLE%%' width='150' class=" fancybox"="" height="150" align="none" resize="crop" separator=", " size="full"}!}{!{/types}!}
{!{/wpv-for-each}!}

#1208065

I have checked the URL you mentioned above, it seems you just need the URL(without HTML image tags) of full size image, and setup the URL in HTML link.

If it is, you can get the image URL with attribute url="true", for example:

{!{types field="product-images"  size="full" url="true"}!}{!{/types}!}

See the document I mentioned above:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
url:
'false'(default) | 'true'
true=output the url of the image instead of the html img tag.

And use it to setup the HTML link, like this:

{!{wpv-for-each field="wpcf-product-images"}!}
<a href="{!{types field="product-images"  size="full" url="true"}!}{!{/types}!}" class="fancybox">
{!{types field='product-images' alt='%%ALT%%' title='%%TITLE%%' width='150' class="fancybox" height='150' align='none' resize='crop' separator=', '}!}{!{/types}!}
</a>
{!{/wpv-for-each}!}
#1208070

My issue is resolved now. Thank you for your help, Luo Yang. The example you gave will allow me to apply what you have taught me to other scenarios.