<p>I have a site with a lot of asset fields, the assets are translatable. The client has added lots into the English fields but many of the Welsh ones haven't been populated. I want to have things fall back to the English assets in cases where there aren't any in the Welsh.</p>

<p>For the sake of example, lets say we're on an entry page where an image has been uploaded in the English locale but one has not been uploaded in the Welsh locale...</p>

<p>I thought this would work:</p>

<pre><code>{% if entry.assetField | length %}
    {# output whichever the current locale is, if it's populated #}
    &lt;img src="{{ entry.assetField.first().getUrl }}" alt="" /&gt;
{% elseif entry.assetField.locale('en_gb') | length %}
    {# fallback to the UK English asset if it exists #}
    &lt;img src="{{ entry.assetField.locale('en_gb').first().getUrl }}" alt="" /&gt;
{% endif %}
</code></pre>

<p>It doesn't. It will pull English assets if I'm viewing the English version of the page, but it does not fall back when we're on the Welsh version of the page. Furthermore, if I am on the Welsh page and change the code to only reference English, like so:</p>

<pre><code>&lt;img src="{{ entry.assetField.locale('en_gb').first().getUrl }}" alt="" /&gt;
</code></pre>

<p>Then it doesn't output an image at all. It's like Craft is ignoring the .locale parameter I'm setting.</p>

<p>I'm certain the local values are correct because those are what are in the Locale setting in the CMS.</p>

<p>What am I doing wrong?</p>

<assets><localization>
Fallbacks for assets not avilable in a locale
# Fallbacks for assets not avilable in a locale

(Asked by: username_0 on 2015-10-16)

I have a site with a lot of asset fields, the assets are translatable. The client has added lots into the English fields but many of the Welsh ones haven't been populated. I want to have things fall back to the English assets in cases where there aren't any in the Welsh.
For the sake of example, lets say we're on an entry page where an image has been uploaded in the English locale but one has not been uploaded in the Welsh locale...
I thought this would work:
{% if entry.assetField | length %}
    {# output whichever the current locale is, if it's populated #}
    
{% elseif entry.assetField.locale('en_gb') | length %}
    {# fallback to the UK English asset if it exists #}
    
{% endif %}

It doesn't. It will pull English assets if I'm viewing the English version of the page, but it does not fall back when we're on the Welsh version of the page. Furthermore, if I am on the Welsh page and change the code to only reference English, like so:


Then it doesn't output an image at all. It's like Craft is ignoring the .locale parameter I'm setting.
I'm certain the local values are correct because those are what are in the Locale setting in the CMS.
What am I doing wrong?

**Tags:** assets, localization


---

## 0 answers

