-1

[Entity file][1]

Controller

thx for your help

J.Ghassen
  • 101
  • 1
  • 1
  • 12
  • 2
    Check this answer http://stackoverflow.com/questions/24022909/display-blob-image-in-symfony-2 there are also 2 other questions refered in answer, check them also. – FZE Feb 16 '16 at 23:27

1 Answers1

0

In Controller

$images = array();
$em = $this->getDoctrine->getManager();
$probleme = $em->getRepository('PiCrowdRiseWebBundle:Probleme')->findAll();
foreach ($probleme as $key => $entity) {
    $images[$key] = base64_encode(stream_get_contents($entity->getFoto()));
}

// ...

return $this->render('PiCrowdRiseWebBundle:Probleme:problemList.html.twig', array(
    'problemes' => $probleme,
    'images' => $images,
));

View:

{% for key, entity in problemes %}
   {# ... #}
   <img alt="Embedded Image" src="data:image/png;base64,{{ images[key] }}" />
   {# ... #}
{% endfor %}
Imanali Mamadiev
  • 2,604
  • 2
  • 15
  • 23
  • It's probably worth mentioning embedding images inside the html is a rather bad idea - rendering performance decreases and page load increases. I think it would be better if the image is served as a `` where the `controller` actually streams the content. This way the page will actually render and the client will be waiting only for the image(s) to load. – tftd Feb 16 '16 at 23:51
  • that doesn't work maybe this line is not correct Embedded Image – J.Ghassen Feb 18 '16 at 08:51