Skip Navigation

[Closed] I want to add images titles in a view with repeater image fields

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 4 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1687405
Knipsel_actuart.JPG

Tell us what you are trying to do?
I want to build a view with an image gallery with a lightbox and I want the title of the image to be the caption in the lightbox.

Is there any documentation that you are following?
I have read dozens of forum issues on this topic but I can't seenm to solve it.

Is there a similar example that we can see?

What is the link to your site?
hidden link
On the page: hidden link for example there is a gallery with 6 images at the end of the article. This is WordPress Blocks. Ik works the way I want this. But I want a caption under each image in the lightbox. I added an repeater field for the post type 'artikelen' for the images in the lightbox. That works. But I cann't add the caption.

The code in the view I used is:

[wpv-for-each field="wpcf-gallery-images"]
<div class="uk-width-1-1 uk-width-medium-1-2 uk-width-large-1-3 gallery-item">

[types field='gallery-images' alt='%%ALT%%' title='%%TITLE%%' width='200' height='200' align='none' resize='crop'][/types]

</div>
[/wpv-for-each]

What I want is the title of the image in the title="%%TITLE%%" of the <a>-tag.

(I used Uikit 2 as a framework: hidden link)

#1688091

Hi, unfortunately the %%TITLE%% placeholder only works inside the Types field shortcode, not inside the wpv-for-each shortcode. That means the title attribute is probably added correctly to the image tag, but not the parent link tag. I don't think you'll be able to solve this with wpv-for-each, because there is no iteration index available during the loop. You'll need to know the iteration index to be able to query the database and get the correct image title based on the loop index. You'll need custom PHP code that iterates over all instances of the repeating field and assembles the link tags similar to this solution from Shane: https://toolset.com/forums/topic/i-need-to-display-the-repeating-image-title-below-the-image/#post-1241867
I'm not sure of your PHP skill level, so let me know if you need more direct guidance on the changes that will be needed to adjust this example to your site's requirements, and I'll be glad to provide some more advice.

The topic ‘[Closed] I want to add images titles in a view with repeater image fields’ is closed to new replies.