I see a few problems. The first is that {{ grid.item(entry.image) }}
is actually an ElementCriteriaModel (i.e. which behaves like an array of images) and not an ElementModel (i.e. a single image), even if only one image is defined. To get the first image you can use entry.image.first
or entry.image[0]
.
The second problem is that in your macro, <img src="{{ thumbnail }}"/>
is trying to set the url string using the whole ElementModel
(or in your case the ElementCriteriaModel). Instead use: {{ thumbnail.url }}
{% macro item(thumbnail) %}
{% if thumbnail %}
<img src="{{ thumbnail.url }}"/>
{% endif %}
{% endmacro %}
{% from _self import item %}
{% for entry in craft.entries.section('handle') %}
{{ item(entry.image.first) }}
{% endfor %}
Update: If on the other hand, for some reason you want to pass the ElementCriteriaModel then you just need to handle it appropriately in the macro:
{% macro item(thumbnail) %}
{% if thumbnail.first %}
<img src="{{ thumbnail.first.url }}"/>
{% endif %}
{% endmacro %}
{% from _self import item %}
{% for entry in craft.entries.section('handle') %}
{{ item(entry.image) }}
{% endfor %}
As a side note — keep in mind that the macro can also exist in the same template and imported using _self
.