How to show image on express entry detail associated entry

Permalink
Any help would be greatly appreciated.

I'm trying to show a list of associated entries on an entry detail block. Just like this tutorial:

https://documentation.concrete5.org/developers/express/using-the-exp...

The only difference is I want to show an image in addition to text fields.
The other fields work correctly, I've added the image in the same manner however I get the following error

Call to a member function getRelativePath() on null



This is the code I'm using.

<?php $works =  $entry->getWorks(); ?>
<table class="table">
    <thead>
    <tr>
        <th>SKU</th>
        <th>Height</th>
        <th>Width</th>
        <th>Depth</th>
        <th>Price</th>
        <th>Primary Image</th>
    </tr>
    </thead>
    <tbody>
    <?php if (count($works)) {
        foreach($works as $work) { ?>

rosie607
 
rosie607 replied on at Permalink Reply
rosie607
Finally figured out a solution.
I think the word 'work' was causing an issue as it's used to get the associated entity. It seems to be with the other fields but not the image field.
Therefore to I had to change the handle to thumbnail_primary_image rather than work_primary_image

Additionally the other fields are with underscores however the image field must use camel case to work. And needed a leading underscore rather than an uppercase character....

So i needed to change the code to

$work->get_thumbnailPrimaryImage()


rather than

$work->getThumbnail_primary_image()