Display blob type image with Symfony 4

  blob, symfony

I’ve tried a lot of solutions suggested in other similar questions but nothing seems to work for me. I have already saved in my database some images in blob type and now i want to display them in my project. The last thing i tried is this solution Display image stored in BLOB database in symfony but is returning this in console:

GET data:image/png;QzpceGFtcHBcdG1wXHBocDYwMTQudG1w net::ERR_INVALID_URL

Please anyone can help? if code is needed i can provide anything. Thanks!


 * @ORMColumn(type="blob")
private $image;

private $rawImage;

public function displayImage(){
    if(null === $this->rawImage) {
        $this->rawImage = "data:image/png;" . base64_encode(stream_get_contents($this->getImage()));

    return $this->rawImage;


public function marketplace (EntityManagerInterface $em, InfoRepository 
$inforepo, TaleRepository $talerepo)
    $infos = $inforepo->findAll();
    if(! $infos){
        $infos = '';

    $images = $inforepo->findImages();
    if(! $images){
        $images = '';

    $boxes = $talerepo->findAll();
    if(! $boxes){
        $boxes = '';

    return $this -> render('home/marketplace.html.twig',[
        'infos' => $infos,
        'selected_boxes' => $boxes,
        'images' => $images


{% for info in infos %}
    <img src="{{ info.displayImage }}" />   
    {{ info.getUrl() }}
{% endfor %}

Source: Symfony Questions