Jump to content

Recommended Posts

Posted

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

Posted
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>";
    }

 

  • Like 2
Posted
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>";
}

 

Posted
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

  • Like 3
Posted
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

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...