You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create an ACF repeater containing an image it will correctly return the structure of the sub fields, but the value for image is all the same for each repeater row. And it is the value of the last image in the repeater set.
The fix is fairly easy, but I cannot provide a real PR right now. Instead I can document the required change here.
The reason is that the two hooks in place here
are not called for each repeating row alternately, but it will call n times load_value and n times format_value. To solve this I simply pushed the values an an array and grab them later from that array.
so I declared:
protected $values = []; // null;
and then assigned this way $this->values[] = $image; // $this->value = $image;
and finally pulled the value here return array_shift( $this->values ); // return $this->value;
i hope this is easy enough to understand to put this back into the main code repo,
Best
-Elmar
The text was updated successfully, but these errors were encountered:
I found it quite difficult to get the image url or post object to display using flexible content. My work around was to comment out this ACF addition and just call in the image via the ID. and do something similar to this:
Just to note this is also an issue with Flexible Content fields where the image returned in all positions is the last one in the Flexible Content set. Presumably the same issue.
If you create an ACF repeater containing an image it will correctly return the structure of the sub fields, but the value for image is all the same for each repeater row. And it is the value of the last image in the repeater set.
The fix is fairly easy, but I cannot provide a real PR right now. Instead I can document the required change here.
The reason is that the two hooks in place here
are not called for each repeating row alternately, but it will call n times load_value and n times format_value. To solve this I simply pushed the values an an array and grab them later from that array.
so I declared:
protected $values = []; // null;
and then assigned this way
$this->values[] = $image; // $this->value = $image;
and finally pulled the value here
return array_shift( $this->values ); // return $this->value;
i hope this is easy enough to understand to put this back into the main code repo,
Best
-Elmar
The text was updated successfully, but these errors were encountered: