I'm using Symfony2 and Twig:
In the Entity Class
/**
* @ORM\Column(name="photo", type="blob", nullable=true)
*/
private $photo;
// ...
public function displayPhoto()
{
return "data:image/png;base64," . base64_encode(stream_get_contents($this->getPhoto()));
}
In the view
<img src="{{ entity.displayPhoto }}">
But if I write
<img src="{{ entity.displayPhoto }}">
<img src="{{ entity.displayPhoto }}">
Then the browser display it only the first time. In the browser (Firefox) The DOM looks like this:
<img src="data:image/png;base64,/9j/4QS...//much more chars//...f7R+ooYz//Z">
<img src="data:image/png;base64,">
So the image content is not present in the second img tag.
Any idea how to show the image more than once?