Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted September 22, 20204 yr Hi, can anyone help me please how to setup custom field for multiple image upload and how to display this field in the record with thumbnail and full size image? If I use this code in the record, its mixed up and pictures are doubled. {{$images = $record->customFieldDisplayByKey('galerie', 'raw') and $thumbs = $record->customFieldDisplayByKey('galerie', 'thumbs');}} {{foreach $images as $image_url}} {{foreach $thumbs as $image_thumbs}} <a href='{$image_url}' data-ipsLightbox><img src='{$image_thumbs}'/></a> {{endforeach}} {{endforeach}} I have uploaded only two pictures Thanks
September 23, 20204 yr You have a foreach loop nested inside the foreach loop - there are two images and two thumbs, so you're going to end up with 4 images in that case. A better loop in your case is probably {{$images = $record->customFieldDisplayByKey('galerie', 'raw') and $thumbs = $record->customFieldDisplayByKey('galerie', 'thumbs');}} {{foreach $images as $k => $image_url}} <a href='{$image_url}' data-ipsLightbox><img src='{$thumbs[$k]}'/></a> {{endforeach}}
September 23, 20204 yr Author thank you very much its better, but click on the thumb is opening other image, not the same. If I have Two images. First open second and other way. If I have three images: same as above, and third is working If I have four images: first open third, second is working, third open forth , forth open first. 🙂
September 24, 20204 yr It would seem to indicate that the 'raw' and 'thumbs' calls are not returning the images in the same order. I would have to debug and test myself to give you a much better answer I'm afraid, but hopefully the suggestion above can guide you on the right track at least.
September 24, 20204 yr 1 minute ago, bfarber said: It would seem to indicate that the 'raw' and 'thumbs' calls are not returning the images in the same order. Yep. We’ve reported this in the past. @Matt wanted to look into it. The full image uses the order of the upload. The thumbs do not.