<p>It's tough to see the full context, just based on what you have here. From what I can tell, it seems like you might need to change <code>&lt;img src="{{ image.file }}" alt=""&gt;</code> to <code>&lt;img src="{{ image.file.first().url }}" alt=""&gt;</code>.</p>

<p>Since the asset field can hold many assets, you have to declare <code>.first()</code> to grab the first one -- even if there's only one image. Then you have to grab the <code>url</code> property from the image, in order to get the correct <code>src</code> value.</p>

CC BY-SA 3.0
2017-06-01T15:48:44.703Z
2017-06-01T15:48:44.703Z
Scott Stubblefield
<p>I am using the <a href="https://github.com/benjamminf/craft-neo/wiki" rel="nofollow noreferrer">Neo</a> plugin in my project. I have made a Neofield <code>article content</code> with several block types in it. Amongst the block types that I have in it, is a <code>gallery</code> as well. Gallery block type has a<code>matrix</code> field <code>imageWithCaption</code>, and the field <code>imageWithCaption</code> has fields <code>file</code> which is the assets field, and fields <code>imageTitle</code> and <code>caption</code> which are plain text fields. I am able to display <code>imageTitle</code> and <code>caption</code> in my template but not a file, or the image itself. This is my template:</p>
<pre><code>     {% for image in block.imageWithCaption %}
        &lt;div class=&quot;large-4 columns&quot;&gt;
          &lt;div class=&quot;media-object stack-for-small&quot;&gt;
            &lt;div class=&quot;media-object-section&quot;&gt;
              &lt;div&gt;
                &lt;img src=&quot;{{ image.file }}&quot; alt=&quot;&quot;&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;media-object-section&quot;&gt;
              &lt;h6&gt;{{ image.title }}&lt;/h6&gt;
              &lt;p&gt;{{ image.caption }}&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      {% endfor %}
</code></pre>
<p>I get an error:</p>
<blockquote>
<p>Object of class Craft\ElementCriteriaModel could not be converted to
string</p>
</blockquote>
<p>What I am doing wrong and how can I display the image?</p>

<assets><matrix><plugin-neo>
Neo plugin - Displaying an image from a Matrix field
# Neo plugin - Displaying an image from a Matrix field

(Asked by: username_0 on 2017-06-01)

I am using the Neo plugin in my project. I have made a Neofield article content with several block types in it. Amongst the block types that I have in it, is a gallery as well. Gallery block type has amatrix field imageWithCaption, and the field imageWithCaption has fields file which is the assets field, and fields imageTitle and caption which are plain text fields. I am able to display imageTitle and caption in my template but not a file, or the image itself. This is my template:
     {% for image in block.imageWithCaption %}
        
          
            
              
                
              
            
            
              {{ image.title }}
              {{ image.caption }}
            
          
        
      {% endfor %}

I get an error:

Object of class Craft\ElementCriteriaModel could not be converted to
string

What I am doing wrong and how can I display the image?

**Tags:** assets, matrix, plugin-neo

---

## 1 answers

### Answer by username_1 on 2017-06-01. Score: 3 | Accepted answer

It's tough to see the full context, just based on what you have here. From what I can tell, it seems like you might need to change `![]({{ image.file }})` to `![]({{ image.file.first().url }})`.

Since the asset field can hold many assets, you have to declare `.first()` to grab the first one -- even if there's only one image. Then you have to grab the `url` property from the image, in order to get the correct `src` value.


---

