These are chat archives for getkirby/chat

28th
Jul 2015
Ivan Cruz
@shiftsave
Jul 28 2015 02:41
hey guys, I'm having trouble loading an image from a select field into my template
tried this - <?php echo $page->image($hero_image) ?>
and <?php echo $page->hero_image()->url() ?>
without luck :\
Ian Cox
@ian-cox
Jul 28 2015 02:42
You need to load the image as an object.
Right now it's just string with the name of the file
You can do that by $files->find()and find by name
Try so
something like that*
Ivan Cruz
@shiftsave
Jul 28 2015 02:46
how do i do that?
Ian Cox
@ian-cox
Jul 28 2015 02:46
<?php echo $page->files()->find('myfile.pdf')->url() ?>
Replace 'myfile.pdf' with $page->hero_image()
Sorry, typing on my phone (and not very well)
Ivan Cruz
@shiftsave
Jul 28 2015 02:52
thanks! ill try
Ian Cox
@ian-cox
Jul 28 2015 02:52
The ->url() Part of the code is expecting an object.
Does that make sense?
This might be even more specific to what you're trying to do.
Ian Cox
@ian-cox
Jul 28 2015 03:01
echo $page->image($page->hero_image())->url();
I believe that should work.
there seem to be many ways to do this, just found another
echo $page->field_name()->toFile()->url();
where field_name() holds a string like “file.zip” or "image.png"