<p>You’re close. When you do this:</p>



<pre class="lang-twig prettyprint-override"><code>{% for image in entry.logos %}
    ...
{% endfor %}
</code></pre>

<p>The code within the for-loop will be repeated for each asset that was assigned to your <code>entry.logos</code> field. Each time, the <code>image</code> variable will be assigned the current asset.</p>

<p>So, if you want to access a field that is <em>on the asset</em> (e.g. your <code>logoUrl</code> field), you would access that via <code>image.logoUrl</code> rather than <code>logos.logoUrl</code>. (You don’t actually have a variable named <code>logos</code>, so if you have <a href="http://buildwithcraft.com/help/dev-mode" rel="nofollow">Dev Mode</a> enabled, that template would be giving you an error about that.)</p>

<pre class="lang-twig prettyprint-override"><code>{% set logo = { width: 175, height: 120, mode: 'fit' } %}

{% for image in entry.logos %}
    &lt;li&gt;&lt;a href="{{ image.logoURL }}"&gt;&lt;img src="{{ image.getUrl(logo) }}" height="{{ image.getHeight(logo) }}" width="{{ image.getWidth(logo) }}" alt="{{ image.title }}"&gt;&lt;/a&gt;&lt;/li&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-10-09T17:19:46.537Z
Thank you, Brandon! That worked. I thought I had tried that variation but alas. We're on our 7th Craft license and loving it.
glider
CC BY-SA 3.0
2014-10-09T17:24:30.300Z
@David Glad to hear that! :)
Brandon Kelly
CC BY-SA 3.0
2014-10-09T17:00:02.007Z
2014-10-09T17:00:02.007Z
Brandon Kelly
<p>I want to setup a custom field to assign a URL for an image.  On the front end I want to output the image and then wrap it in a URL. I've setup a field called 'logoURL' but not sure how to access that data.  What I have isn't working and I've tried several variations.</p>

<pre><code>{% set logo = { width: 175, height: 120, mode: 'fit' } %}

{% for image in entry.logos %}
    &lt;li&gt;
        &lt;a href="{{ logos.logoURL }}"&gt;&lt;img src="{{ image.getUrl(logo) }}" height="{{ image.getHeight(logo) }}" width="{{ image.getWidth(logo) }}" alt="{{ image.title }}"&gt;&lt;/a&gt;          
    &lt;/li&gt;
{% endfor %}
</code></pre>

<assets>
How do I access a custom Asset field within an Assets field?
# How do I access a custom Asset field within an Assets field?

(Asked by: username_0 on 2014-10-09)

I want to setup a custom field to assign a URL for an image.  On the front end I want to output the image and then wrap it in a URL. I've setup a field called 'logoURL' but not sure how to access that data.  What I have isn't working and I've tried several variations.
{% set logo = { width: 175, height: 120, mode: 'fit' } %}

{% for image in entry.logos %}
    
                  
    
{% endfor %}

**Tags:** assets


---

## 1 answers

### Answer by username_1 on 2014-10-09. Score: 2

You’re close. When you do this:
{% for image in entry.logos %}
    ...
{% endfor %}

The code within the for-loop will be repeated for each asset that was assigned to your entry.logos field. Each time, the image variable will be assigned the current asset.
So, if you want to access a field that is on the asset (e.g. your logoUrl field), you would access that via image.logoUrl rather than logos.logoUrl. (You don’t actually have a variable named logos, so if you have Dev Mode enabled, that template would be giving you an error about that.)
{% set logo = { width: 175, height: 120, mode: 'fit' } %}

{% for image in entry.logos %}
    
{% endfor %}

> **Comments:**
> **username_0**: Thank you, Brandon! That worked. I thought I had tried that variation but alas. We're on our 7th Craft license and loving it.  
> **username_1**: @David Glad to hear that! :)  

---

