Skip Navigation

[Resolved] Make an multiple instance image field cliquable

This support ticket is created 6 years, 6 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by francoisP-5 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#774392

OK, in my CPT (disques) I have a field with multiple instances called "images". Here is the code I use to display those images.

[wpv-conditional if="( $(wpcf-images) gt '' )"]
[types field='images' alt='%%ALT%%' title='%%TITLE%%' width='575px' align='none' resize='proportional' separator=', '][/types]
[/wpv-conditional]

An example here : hidden link

What I want to do is that I would like to make these images on the right side cliquable so that when a user click on the image, he/she will see the (larger) original image displayed.

My question is: How should I tackle this?
Thanks ahead for any hints. BTW, I did search the forum but did not find any related information. Maybe my way of searching, sorry. François

#775635

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi François

You can get quite creative with the separator attribute when inserting repeating fields, such that you use closing and opening li tags, for example, to generate an unordered list, rather than simply separating items with a comma.

But that doesn't help you here because you need to dynamically output the image URLs for the links, so you will need to use the wpv-for-each shortcode to iterate over the occurrences of the image field.

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

For your field "images" that would look something like this:

[wpv-for-each field='wpcf-images']
<a href="[types field='images' size='full' url='true'][/types]">[types field='images' alt='%%ALT%%' title='%%TITLE%%' width='575px' align='none' resize='proportional'][/types]</a>
[/wpv-for-each]
#777517

Thank you very much. This did the job numero uno 🙂
Have a very nice day!
François