Getting error in template: Impossible to access an attribute ("getUrl") on a NULL variable ("")
You can just test if image is defined first using:

{% set image = block.image.first() %}
{% if image %}
    &lt;a href="{{ image.getUrl() }}"&gt;...&lt;/a&gt;
{% endif %}