<p>I don't know if it's the cause of the error you're receiving or not, but this is incorrect Twig syntax:</p>

<pre><code>{% set image = '{{ websitePreferences.placeholderImage.first.url }}' %}
</code></pre>

<p>You'll never need to nest <code>{{ }}</code> inside of <code>{% %}</code> or visa versa in Twig.</p>

<p>This is correct:</p>

<pre><code>{% set image = websitePreferences.placeholderImage.first() %}
</code></pre>

CC BY-SA 4.0
2018-09-14T20:50:05.813Z
I try the above >>>> {% set image = websitePreferences.placeholderImage.first() %} and I doesn't work for me.
it only output the name of the image "<img src="Craft Cms Vs Wordpress Card">"
user3188831
CC BY-SA 3.0
2017-04-11T23:05:25.370Z
2017-04-11T23:05:25.370Z
Brad Bell
<p>Should be:</p>
<pre><code>{% set image = websitePreferences.placeholderImage.first.url() %}
</code></pre>

CC BY-SA 4.0
2021-02-26T03:06:09.350Z
2021-02-26T03:06:09.350Z
Damien Buckley
<p>I've setup a global asset field so that a client can change a placeholder image that gets used throughout their website. I'm using the Imager plugin for my image transforms.</p>

<p>The following image code works fine when using a hard-coded image URL:</p>

<pre><code>{% set image = 'http://placehold.it/450x225/eee/eee' %}
{% set transformedImage = craft.imager.transformImage(image, { width: 450, height: 225, }) %}
&lt;img src="{{ transformedImage.url }}" /&gt;
</code></pre>

<p>But when I replace the hard-coded image URL with the global asset field, it doesn't work:</p>

<pre><code>{% set image = '{{ websitePreferences.placeholderImage.first.url }}' %}
{% set transformedImage = craft.imager.transformImage(image, { width: 450, height: 225, }) %}
&lt;img src="{{ transformedImage.url }}" /&gt;
</code></pre>

<p>I get this error message (Craft/Exception):</p>

<blockquote>
  <p>Source folder “/Users/stephen/Repositories/repo-name-here/public_html./” does not exist</p>
</blockquote>

<p>If I output the global asset field elsewhere in the template, I get this:</p>

<blockquote>
  <p><a href="http://my-locl-url.dev/uploads/images/Placeholders/placeholder-image.png" rel="nofollow noreferrer">http://my-locl-url.dev/uploads/images/Placeholders/placeholder-image.png</a></p>
</blockquote>

<p>If I hard-code this URL into my image code, the image works fine. So does anyone have any idea why using a global for the placeholder image in this way isn't working? Thanks for any help.</p>

<globals><plugin-imager>
Trying to set an image URL using a global asset field
# Trying to set an image URL using a global asset field

(Asked by: username_0 on 2017-04-11)

I've setup a global asset field so that a client can change a placeholder image that gets used throughout their website. I'm using the Imager plugin for my image transforms.
The following image code works fine when using a hard-coded image URL:
{% set image = 'http://placehold.it/450x225/eee/eee' %}
{% set transformedImage = craft.imager.transformImage(image, { width: 450, height: 225, }) %}


But when I replace the hard-coded image URL with the global asset field, it doesn't work:
{% set image = '{{ websitePreferences.placeholderImage.first.url }}' %}
{% set transformedImage = craft.imager.transformImage(image, { width: 450, height: 225, }) %}


I get this error message (Craft/Exception):

Source folder “/Users/stephen/Repositories/repo-name-here/public_html./” does not exist

If I output the global asset field elsewhere in the template, I get this:

http://my-locl-url.dev/uploads/images/Placeholders/placeholder-image.png

If I hard-code this URL into my image code, the image works fine. So does anyone have any idea why using a global for the placeholder image in this way isn't working? Thanks for any help.

**Tags:** globals, plugin-imager


---

## 2 answers

### Answer by username_1 on 2017-04-11. Score: 3 | Accepted answer

I don't know if it's the cause of the error you're receiving or not, but this is incorrect Twig syntax:
{% set image = '{{ websitePreferences.placeholderImage.first.url }}' %}

You'll never need to nest {{ }} inside of {% %} or visa versa in Twig.
This is correct:
{% set image = websitePreferences.placeholderImage.first() %}

> **Comments:**
> **username_2**: I try the above >>>> {% set image = websitePreferences.placeholderImage.first() %} and I doesn't work for me. it only output the name of the image "<img src="Craft Cms Vs Wordpress Card">"  

---

### Answer by username_3 on 2021-02-26. Score: 1

Should be:
{% set image = websitePreferences.placeholderImage.first.url() %}


---

