How do you template an IF statement to avoid an error if an image is not assigned
You're close...

{% set programImage = entry.programImage.one() %}
{% if programImage %}
    &lt;img src="{{ programImage.getUrl() }}" alt=""/&gt;
{% endif %}


You get the the asset model (or null), then check if you actually have it, then finally use it.

It's essentially the same in Craft 2.