Display a Matrix field block entry when the block's entry exists I have a videoPost block in a Matrix field. Each videoPost has a imageField. I am trying to display the block’s image if imageField is defined. This is returning images for each block that has imageField defined when I only want to return the specific block’s image.

{% for block in entry.matrixField.type('videoPost') %}
    {% if block.imageField | length %}
        {% for asset in block.imageField %}
            &lt;img src="{{asset.getUrl}}" alt="{{ asset.title }}" /&gt;
        {% endfor %}
    {% endif %}
{% endfor %}
Try replacing

{% for asset in block.imageField %}
    &lt;img src="{{asset.getUrl}}" alt="{{ asset.title }}" /&gt;
{% endfor %}


with

{% set asset = block.imageField.first() %}
&lt;img src="{{asset.getUrl}}" alt="{{ asset.title }}" /&gt;


If you're using Craft 3, replace .first() with .one()