I've been using this example to eager load images, stored in an Assets field which is located in a Matrix field.
My query looks like this:
{% set entries = craft.entries.section('project')
.with(['projectMatrix.imageBlock:imageFile']) %}
Where projectMatrix
is a Matrix field, imageBlock
is a Matrix block type and imageFile
is an Asset field inside imageBlock
.
But how do I reference the that image in my templates?
{% for entry in entries %}
{% set matrixImage = entry.projectMatrix.type('imageBlock')[0].imageFile[0] ?? null %}
...
{% endfor %}
This is always be null
, when eager loaded