Answers.Body: <p>You would usually display the image with </p>
  
  <pre><code>{% for pageImage in entry.pageImage %}
      &lt;img src="{{ pageImage.getUrl() }}"&gt; 
  {% endfor %}
  </code></pre>
  
  <p>But this only works if you enabled the public url option for the asset source. There is a light switch if those assets should have urls or not in your cp</p>
  
  <p>It also has a <code>getImg()</code> function</p>
  
  <pre><code>/**
   * Returns an &lt;img&gt; tag based on this asset.
   *
   * @return \Twig_Markup|null
   */
  public function getImg()
  {
      if ($this-&gt;kind == 'image' &amp;&amp; $this-&gt;getHasUrls())
      {
          $img = '&lt;img src="'.$this-&gt;getUrl().'" width="'.$this-&gt;getWidth().'" height="'.$this-&gt;getHeight().'" alt="'.HtmlHelper::encode($this-&gt;title).'" /&gt;';
          return TemplateHelper::getRaw($img);
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-27T01:29:56.163Z
Answers.LastActivityDate: 2017-12-27T01:29:56.163Z
Answers.UserDisplayName: Robin Schambach
Body: <p>just getting start with Craft, and I can't figure out why my images won't output. Any time I try to output even the path to the url of my image, I get an <code>internal error: Craft\AssetFileModel and its behaviors do not have a method or closure named [...]</code>.</p>
  
  <p>I can successfully do this:</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% if entry.pageImage | length %}
      {% for pageImage in entry.pageImage %}
          {{ pageImage }}
      {% endfor %}
  {% endif %}
  </code></pre>
  
  <p>Which just outputs the title of the image. But I want to display the image. I was expecting to be able to be able to use <code>{{pageImage.getUrl()}}</code> or <code>{{pageImage.url}}</code> or <code>{{pageImage.fileName}}</code> but these will throw the aforementioned error. How do I output an image?</p>
  
Tags: <assets><image>
Title: Can't output an image
ThreadText: # Can't output an image
  
  (Asked by: username_0 on 2017-12-27)
  
  just getting start with Craft, and I can't figure out why my images won't output. Any time I try to output even the path to the url of my image, I get an `internal error: Craft\AssetFileModel and its behaviors do not have a method or closure named [...]`.
  
  I can successfully do this:
  
  ```twig
  {% if entry.pageImage | length %}
      {% for pageImage in entry.pageImage %}
          {{ pageImage }}
      {% endfor %}
  {% endif %}
  
  ```
  
  Which just outputs the title of the image. But I want to display the image. I was expecting to be able to be able to use `{{pageImage.getUrl()}}` or `{{pageImage.url}}` or `{{pageImage.fileName}}` but these will throw the aforementioned error. How do I output an image?
  
  **Tags:** assets, image
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-12-27. Score: 2 | Accepted answer
  
  You would usually display the image with
  
  ```
  {% for pageImage in entry.pageImage %}
      <img src="{{ pageImage.getUrl() }}"> 
  {% endfor %}
  
  ```
  
  But this only works if you enabled the public url option for the asset source. There is a light switch if those assets should have urls or not in your cp
  
  It also has a `getImg()` function
  
  ```
  /**
   * Returns an <img> tag based on this asset.
   *
   * @return \Twig_Markup|null
   */
  public function getImg()
  {
      if ($this->kind == 'image' && $this->getHasUrls())
      {
          $img = '<img src="'.$this->getUrl().'" width="'.$this->getWidth().'" height="'.$this->getHeight().'" alt="'.HtmlHelper::encode($this->title).'" />';
          return TemplateHelper::getRaw($img);
      }
  }
  
  ```
  
  
  ---
  
  