title: Symfony2 - base64_decode in twig
body: <p>I need to display a picture in my twig template. I get this picture in my controller as string encoded in base64, so I created a personal function in my service to decode the base64 :</p>
  
  <pre><code>public function base64ToImg($base64)
  {
      $img_str = 'image/png;base64,'.$base64;
      $img_data = explode(";",$img_str);
      $type_img = $img_data[0];
      $final_img = explode(",",$img_data[1]);
      header("Content-type:".$type_img);
  
      return base64_decode($final_img[1]);
  }
  </code></pre>
  
  <p>and in my controller : </p>
  
  <pre><code>$logo = $this-&gt;container-&gt;get('services.utils')-&gt;base64ToImg($mydata);
  echo $logo;
  die();
  </code></pre>
  
  <p>It works, but when i send <code>$logo</code> to my template with a <code>render</code>, the picture isn't displayed with <code>{{ logo }}</code>. I tried to create my own twig function too but doesn't works also...</p>
  
  <p>There is a solution ?</p>
  
  <p>Thanks</p>