picarica Posted May 23, 2020 Share Posted May 23, 2020 so i have some experience with repeat fields i used it past my websited but on this new website it doesnt seem to work what i did is i made repeat field "produkt_repeat_field" and inside i have put "r_galeria_image" so logically when i ahve something like this foreach ($page->produkt_repeat_field as $building) { $thumbnail = $building->r_galeria_image->size(450, 250); echo"<article>"; echo "<a href='{$building->r_galeria_image}' class='fresco' data-fresco-caption='{$building->r_galeria_image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; } it should work right ? but i get error Error: Exception: Method Pageimages::size does not exist or is not callable in this context (in /www/pw/weby/wire/core/Wire.php line 529) and yes i checked i uploaded 4 images i am so confused about this Link to comment Share on other sites More sharing options...
psy Posted May 23, 2020 Share Posted May 23, 2020 28 minutes ago, picarica said: $thumbnail = $building->r_galeria_image->size(450, 250); You are looping through the repeater field items (buildings) but not their images (one or many per building) as well. By default an 'images' field can hold multiple images and you simply loop through them. If the only field in your repeater is 'r_galeria_image' then it's unnecessary to have a repeater. foreach ($page->r_galeria_image as $image) { $thumbnail = $image->size(450, 250); echo"<article>"; echo "<a href='{$image->url}' class='fresco' data-fresco-caption='{$image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; } 2 Link to comment Share on other sites More sharing options...
kixe Posted May 24, 2020 Share Posted May 24, 2020 foreach ($page->produkt_repeat_field as $building) { $image = $building->r_galeria_image->first(); $thumbnail = $image->size(450, 250); echo "<article>"; echo "<a href='{$image->url}' class='fresco' data-fresco-caption='{$image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo "</article>"; } Link to comment Share on other sites More sharing options...
picarica Posted May 24, 2020 Author Share Posted May 24, 2020 11 hours ago, psy said: You are looping through the repeater field items (buildings) but not their images (one or many per building) as well. By default an 'images' field can hold multiple images and you simply loop through them. If the only field in your repeater is 'r_galeria_image' then it's unnecessary to have a repeater. foreach ($page->r_galeria_image as $image) { $thumbnail = $image->size(450, 250); echo"<article>"; echo "<a href='{$image->url}' class='fresco' data-fresco-caption='{$image->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; } omg thank you so much i was so stupid ? i changed it to this and it work foreach ($page->produkt_repeat_field as $building) { foreach ($building->r_galeria_image as $obrazok){ $thumbnail = $obrazok->size(450, 250); echo"<article>"; echo "<a href='{$obrazok->url}' class='fresco' data-fresco-caption='{$obrazok->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; } } i totally forgot i was looping throught repeat fields and not throught gallery, thank you sorry for my mistake 3 Link to comment Share on other sites More sharing options...
psy Posted May 24, 2020 Share Posted May 24, 2020 @picarica all good, glad you solved it and no need to apologise ? 1 Link to comment Share on other sites More sharing options...
EyeDentify Posted May 28, 2020 Share Posted May 28, 2020 On 5/24/2020 at 11:12 AM, picarica said: omg thank you so much i was so stupid ? i changed it to this and it work foreach ($page->produkt_repeat_field as $building) { foreach ($building->r_galeria_image as $obrazok){ $thumbnail = $obrazok->size(450, 250); echo"<article>"; echo "<a href='{$obrazok->url}' class='fresco' data-fresco-caption='{$obrazok->description}' data-fresco-group-options='preload: [1,2], effects: {spinner: {show:150, hide:150 } }' data-fresco-group='kolace'><img src='$thumbnail->url' alt='obrazok'></a>"; echo"</article>"; } } i totally forgot i was looping throught repeat fields and not throught gallery, thank you sorry for my mistake The image field trip up even the most seasoned developer from time to time. I almost allways have the PW API documents open in a tab when i do PW dev because you can´t keep everything in your head. It´s a great resource for all devs, and ofcourse using the TracyDebugger module by @dragan 1 Link to comment Share on other sites More sharing options...
kongondo Posted May 28, 2020 Share Posted May 28, 2020 13 minutes ago, EyeDentify said: TracyDebugger module by @dragan Ahem...you mean @adrian ? 1 Link to comment Share on other sites More sharing options...
EyeDentify Posted May 28, 2020 Share Posted May 28, 2020 1 hour ago, kongondo said: Ahem...you mean @adrian ? Yes ? my misstake. i meant @adrian Things gets confusing sometimes. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now