Body: <p>I'm trying to send a meta-data image from an entry template to the main layout template.  The image is in a matrix block on the entry.  It comes out correctly when I call it on the entry page, but when I try to pass it to the layout it doesn't see it and reverts to the default image called in the layout.  Any help is appreciated</p>
  
  <p>_Layout template</p>
  
  <pre><code>&lt;meta property="twitter:image:src" content={% if twitterpic is defined %}"{{ twitterpic }}"{%else%}"{{ siteImage.getUrl('twitterPic') }}" {%endif%}/&gt;
  </code></pre>
  
  <p>_entry template</p>
  
  <pre><code>{#  social image  #}
  {% for block in entry.projectImage%}
  {% set image for block.projectImage.first() %}
  {% set twitterpic =image.getUrl('twitterPic') %}
  {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T15:48:04.393Z
Comments.Text: This seems like a duplicate of: http://craftcms.stackexchange.com/q/153/177
Comments.UserDisplayName: Victor
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T16:07:30.603Z
Comments.Text: Hi @Micah, and welcome to the Craft CMS Stack Exchange site! As Victor In pointed out, a similar question has already been asked and answered here. You might also find [this question](http://craftcms.stackexchange.com/questions/859/how-do-i-add-an-html-block-from-template-extension-to-main-layout-template-i-e/860#860) on passing meta tags useful.
Comments.UserDisplayName: Matt Stein
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T16:47:10.023Z
Comments.Text: I'm in the same block, and all my other variables are passing fine.  That's not the problem.  The problem seems to be specific to the asset call
Comments.UserDisplayName: Micah Morgan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T17:13:24.873Z
Comments.Text: @MicahMorgan As the linked answer indicates, this is a scope issue. You're defining `twitterpic` within your foor loop, but you first need to define it *outside the loop* if you want it to be available elsewhere. You're also running `.getUrl('twitterPic')` twice. You should either pass the asset (`image`) or pass the URL reference (`twitterpic`).
Comments.UserDisplayName: Matt Stein
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T18:21:19.817Z
Comments.Text: thank you for the clarification.  I read it all, but it didn't sink in
Comments.UserDisplayName: Micah Morgan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-14T20:26:36.670Z
Comments.Text: @MicahMorgan "I read it all, but it didn't sink in" explains most of the problems I have :)
Comments.UserDisplayName: Matt Stein
Tags: <templating>
Title: How do I pass an image to the _layout
ThreadText: # How do I pass an image to the _layout
  
  (Asked by: username_0 on 2014-07-14)
  
  I'm trying to send a meta-data image from an entry template to the main layout template. The image is in a matrix block on the entry. It comes out correctly when I call it on the entry page, but when I try to pass it to the layout it doesn't see it and reverts to the default image called in the layout. Any help is appreciated
  
  \_Layout template
  
  ```
  <meta property="twitter:image:src" content={% if twitterpic is defined %}"{{ twitterpic }}"{%else%}"{{ siteImage.getUrl('twitterPic') }}" {%endif%}/>
  
  ```
  
  \_entry template
  
  ```
  {#  social image  #}
  {% for block in entry.projectImage%}
  {% set image for block.projectImage.first() %}
  {% set twitterpic =image.getUrl('twitterPic') %}
  {% endfor %}
  
  ```
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: This seems like a duplicate of: http://craftcms.stackexchange.com/q/153/177  
  > **username_2**: Hi @username_0, and welcome to the Craft CMS Stack Exchange site! As username_1 In pointed out, a similar question has already been asked and answered here. You might also find [this question](http://craftcms.stackexchange.com/questions/859/how-do-i-add-an-html-block-from-template-extension-to-main-layout-template-i-e/860#860) on passing meta tags useful.  
  > **username_0**: I'm in the same block, and all my other variables are passing fine.  That's not the problem.  The problem seems to be specific to the asset call  
  > **username_2**: @username_0 As the linked answer indicates, this is a scope issue. You're defining `twitterpic` within your foor loop, but you first need to define it *outside the loop* if you want it to be available elsewhere. You're also running `.getUrl('twitterPic')` twice. You should either pass the asset (`image`) or pass the URL reference (`twitterpic`).  
  > **username_0**: thank you for the clarification.  I read it all, but it didn't sink in  
  > **username_2**: @username_0 "I read it all, but it didn't sink in" explains most of the problems I have :)  
  
  ---
  
  ## 0 answers
  
  