Using the Image Type in a Structure

I am using an image type inside a structure in my blueprint like below. Everything works fine when I am in the panel, but I am not sure how to access the image or image url.

    label: Cars
    type: structure
    style: table
    entry: >
        label: Name
        type: text
        label: Details
        type: textarea
        label: Vehicle Image
        type: image

When I call the below code it only gives me the image name. I’ve tried using url() but it only gives and not the actual url to the image.

<?php echo $car->picture()->image() ?>

1 Like

Replace image() by toFile() - >url()

1 Like

The image field saves the name of the image. So to fetch the image in your templates your have to pass the value of the field to the image method like this:

<?php echo $page->image($car->picture()) ?>
1 Like

This worked for me.

<?php echo $car->picture()->toFile() ?>

1 Like

Sorry for my super short answer, I was writing from my phone :slight_smile:

We’re writing a tutorial for next week on Structures at @macotuts. Using images inside the field will definitely be a part of it as it’s an often encountered need!

Glad you found your answer.


1 Like