Answers.Body: <p>Hey Jeremy give this a shot to see if it works (from <a href="https://craftcms.com/docs/templating/craft.assets" rel="nofollow noreferrer">craft.assets</a>)</p>
  
  <pre><code>{% for asset in entry.imagePrimary %}
       &lt;img src="{{ asset.url }}" alt="{{ asset.title }}"&gt;                               
  {% endfor %}
  </code></pre>
  
  <p>If this doesn't clear it up, I'd double check the field Handle to make sure it's spelled correctly and there is an image within one of your entries.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-08T15:02:32.190Z
Answers.Text: Shouldn't `{{ entry.title }}` be `{{ asset.title }}`?
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-08T20:59:41.470Z
Answers.Text: Yes you are correct. Editing to fix.
Answers.UserDisplayName: Adam McCombs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-29T03:45:31.980Z
Answers.Text: Why is iterating over the asset object necessary? Why doesn't `entry.imagePrimary.url` work?
Answers.UserDisplayName: emc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-29T04:23:22.513Z
Answers.Text: Got it - `{{ entry.imagePrimary }}` is an array! When defining an asset field, there is a field to denote how many elements this asset can hold. To access the first element in the array, use `{{ entry.imagePrimary[0].url }}` !!
Answers.UserDisplayName: emc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-08T06:24:57.020Z
Answers.LastActivityDate: 2017-10-24T15:25:35.540Z
Answers.LastEditDate: 2017-10-24T15:25:35.540Z
Answers.UserDisplayName: Adam McCombs
Body: <p>I'm new to Craft and having a very hard time calling the URL from a field I created called <code>imagePrimary</code></p>
  
  <p>I've read this extensively but still no luck. <a href="https://craftcms.com/docs/assets-fields" rel="nofollow noreferrer">https://craftcms.com/docs/assets-fields</a></p>
  
  <pre><code>{% include 'header.html' %}
  
  {% block content %}
  
  {% for entry in craft.entries.section('projects').limit(500).find() %}  
  
  &lt;div class="wrapper"&gt;
  
      &lt;div class="row entry feed linked"&gt;
  
          &lt;div class="title"&gt;&lt;a href="{{ entry.url }}"&gt;&lt;p&gt;&lt;span&gt;{{ entry.studio }}&lt;/span&gt;{{ entry.title }}&lt;/p&gt;&lt;/a&gt;&lt;/div&gt;
  
          &lt;div class="col-xs-12 col-md-8"&gt;
  
              &lt;div class="featured image" style="background-image: url(
  
                  {% for asset in entry.imagePrimary %}
                       {{ asset.url() }}                                  
                  {% endfor %}
  
              )"&gt;&lt;/div&gt;
  
          &lt;/div&gt;
  
          &lt;div class="col-md-4 secondary"&gt;
  
              &lt;div class="featured image secondary" style="background-image: url()"&gt;&lt;/div&gt;
              &lt;div class="featured image secondary" style="background-image: url()"&gt;&lt;/div&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  {% endfor %}
  
  {% endblock %}
  
  {% include 'footer.html' %}
  </code></pre>
  
Tags: <assets>
Title: How to get asset URL from field in template
ThreadText: # How to get asset URL from field in template
  
  (Asked by: username_0 on 2014-12-08)
  
  I'm new to Craft and having a very hard time calling the URL from a field I created called `imagePrimary`
  
  I've read this extensively but still no luck. <https://craftcms.com/docs/assets-fields>
  
  ```
  {% include 'header.html' %}
  
  {% block content %}
  
  {% for entry in craft.entries.section('projects').limit(500).find() %}  
  
  <div class="wrapper">
  
      <div class="row entry feed linked">
  
          <div class="title"><a href="{{ entry.url }}"><p><span>{{ entry.studio }}</span>{{ entry.title }}</p></a></div>
  
          <div class="col-xs-12 col-md-8">
  
              <div class="featured image" style="background-image: url(
  
                  {% for asset in entry.imagePrimary %}
                       {{ asset.url() }}                                  
                  {% endfor %}
  
              )"></div>
  
          </div>
  
          <div class="col-md-4 secondary">
  
              <div class="featured image secondary" style="background-image: url()"></div>
              <div class="featured image secondary" style="background-image: url()"></div>
  
          </div>
  
      </div>
  
  </div>
  
  {% endfor %}
  
  {% endblock %}
  
  {% include 'footer.html' %}
  
  ```
  
  **Tags:** assets
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-08. Score: 9
  
  Hey username_0 give this a shot to see if it works (from [craft.assets](https://craftcms.com/docs/templating/craft.assets))
  
  ```
  {% for asset in entry.imagePrimary %}
       <img src="{{ asset.url }}" alt="{{ asset.title }}">                               
  {% endfor %}
  
  ```
  
  If this doesn't clear it up, I'd double check the field Handle to make sure it's spelled correctly and there is an image within one of your entries.
  
  > **Comments:**
  > **username_2**: Shouldn't `{{ entry.title }}` be `{{ asset.title }}`?  
  > **username_1**: Yes you are correct. Editing to fix.  
  > **username_3**: Why is iterating over the asset object necessary? Why doesn't `entry.imagePrimary.url` work?  
  > **username_3**: Got it - `{{ entry.imagePrimary }}` is an array! When defining an asset field, there is a field to denote how many elements this asset can hold. To access the first element in the array, use `{{ entry.imagePrimary[0].url }}` !!  
  
  ---
  
  