When I try to get the URL from the new image field in 2.3 it doesn’t work
<?= $page->picturefield()->url() ?>
But I’m expecting it to return http://root.dev/01-parent/02-child/filename.jpg
toFile() function doesn’t seem to work on the new field. Works fine with a select field or the selector plugin.
This should work:
or if not, then:
Yes, they both work. I guess I’m just used to the
toFile()->url() method, but this will do the trick
Either way, is this expected behavior for the image field’s
toFile() should actually also work:
It appears to only work for me when the template corresponds to the same level…
The image is /01-parent/02-child/filename.jpg and I can use any of the above methods just fine in child.php template
But if I want to display it for in a list/grid in parent.php template it throws an error
Fatal error: Call to a member function url() on null in /Applications/MAMP/h...
<?php foreach($page->children()->visible() as $p): ?>
<strong><?= $p->picturefield()->toFile()->url() ?></strong>
<?php endforeach; ?>
I tested this in a starterkit and it works on all levels. Have you made sure that the field contains an image filename in every page? Or better still, use an if statement to check that the field is not empty and the image exists.
Okay that seems to have been the problem
Really weird way of doing things, but it works, i guess.
Any plugins that can be made so you can simply do:
where that would output the url?