mardiv Posted September 22, 2020 Posted September 22, 2020 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
bfarber Posted September 23, 2020 Posted September 23, 2020 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}} Â
mardiv Posted September 23, 2020 Author Posted September 23, 2020 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. 🙂 Â
bfarber Posted September 24, 2020 Posted September 24, 2020 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.
opentype Posted September 24, 2020 Posted September 24, 2020 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.Â
Recommended Posts