Answers.Body: <p>First you need to get the entry for the main page. There are a number of ways you might do that (check the <a href="https://craftcms.com/docs/templating/craft.entries" rel="nofollow noreferrer">craft.entries</a> documentation). One would be to fetch it by section handle, so assuming the main page has section handle of <code>mainPage</code>, you can do this:</p>
  
  <pre><code>{% set mainPage = craft.entries.section('mainPage').first %}
  </code></pre>
  
  <p>And then you can get the from the main page asset as before:</p>
  
  <pre><code>{% for asset in mainPage.donateHeaderImage %}
    &lt;img src="{{ asset.url }}"&gt;
  {% endfor %}
  </code></pre>
  
  <hr>
  
  <p>To be safe, you should always handle the possibility that <code>craft.entries</code> won't return anything (maybe the mainPage section handle changed).</p>
  
  <p>So either test it:</p>
  
  <pre><code>{% set mainPage = craft.entries.section('mainPage').first %}
  {% if mainPage %}
    {% for asset in mainPage.donateHeaderImage %}
      &lt;img src="{{ asset.url }}"&gt;
    {% endfor %}
  {% endif %}
  </code></pre>
  
  <p>Or use the powerful <a href="https://twig.symfony.com/doc/2.x/templates.html#other-operators" rel="nofollow noreferrer">null-coalescing operator</a>:</p>
  
  <pre><code>{% for asset in craft.entries.section('mainPage').first.donateHeaderImage ?? [] %}
    ...
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-10T23:15:21.440Z
Answers.Text: Awesome you saved my butt again Marion! And the IF statement is just to be safe that craft.entries will return something, correct?
Answers.UserDisplayName: kingkelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-11T14:16:17.863Z
Answers.Text: That's right. It's a good habit to get into _always_ checking.
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-10T22:52:08.827Z
Answers.LastActivityDate: 2017-10-10T22:52:08.827Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>I'm trying to display an asset that the client has selected to show up on the main page, and have it display on a totally different page. This sounds simple but I keep getting errors (and im learning).</p>
  
  <p>Main page asset:</p>
  
  <pre><code>{% for asset in entry.donateHeaderImage %}
     &lt;img src="{{ asset.url }}"&gt;
  {% endfor %}
  </code></pre>
  
  <p>Not sure how to display that asset on a different page in Craft. </p>
  
Tags: <assets><entry>
Title: Grabbing an asset field from Page A to display on Page B
ThreadText: # Grabbing an asset field from Page A to display on Page B
  
  (Asked by: username_0 on 2017-10-10)
  
  I'm trying to display an asset that the client has selected to show up on the main page, and have it display on a totally different page. This sounds simple but I keep getting errors (and im learning).
  
  Main page asset:
  
  ```
  {% for asset in entry.donateHeaderImage %}
     <img src="{{ asset.url }}">
  {% endfor %}
  
  ```
  
  Not sure how to display that asset on a different page in Craft.
  
  **Tags:** assets, entry
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-10. Score: 3 | Accepted answer
  
  First you need to get the entry for the main page. There are a number of ways you might do that (check the [craft.entries](https://craftcms.com/docs/templating/craft.entries) documentation). One would be to fetch it by section handle, so assuming the main page has section handle of `mainPage`, you can do this:
  
  ```
  {% set mainPage = craft.entries.section('mainPage').first %}
  
  ```
  
  And then you can get the from the main page asset as before:
  
  ```
  {% for asset in mainPage.donateHeaderImage %}
    <img src="{{ asset.url }}">
  {% endfor %}
  
  ```
  
  ---
  
  To be safe, you should always handle the possibility that `craft.entries` won't return anything (maybe the mainPage section handle changed).
  
  So either test it:
  
  ```
  {% set mainPage = craft.entries.section('mainPage').first %}
  {% if mainPage %}
    {% for asset in mainPage.donateHeaderImage %}
      <img src="{{ asset.url }}">
    {% endfor %}
  {% endif %}
  
  ```
  
  Or use the powerful [null-coalescing operator](https://twig.symfony.com/doc/2.x/templates.html#other-operators):
  
  ```
  {% for asset in craft.entries.section('mainPage').first.donateHeaderImage ?? [] %}
    ...
  
  ```
  
  > **Comments:**
  > **username_0**: Awesome you saved my butt again username_1! And the IF statement is just to be safe that craft.entries will return something, correct?  
  > **username_1**: That's right. It's a good habit to get into _always_ checking.  
  
  ---
  
  