KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Displaying a BLOB #1992

Open Richb201 opened this topic on on Mar 25, 2021 - 3 comments

Richb201 commented on Mar 25, 2021

I have an image in a BLOB in a remote mysql table. The field is called img_BLOB and should be used instead of the thumbnail_url. How would I get it to appear in the table below?

<?php

Table::create(array(
    "dataStore" => $this->dataStore("word"),
    "showFooter" => true,
    "columns" => array(
        "description",
        "thumbnail_url" => array(
            "formatValue"=> "<img width='500px' height='400px' src='".base_url()."/@value' />"
        ),
    ),
    "cssClass"=>array(
        "table"=>"table-bordered table-striped table-hover"
    )
));
?>
KoolReport commented on Mar 25, 2021

You do:

"formatValue"=> "<img width='500px' height='400px' src='data:image/png;base64, @value' />"
Richb201 commented on Mar 25, 2021

That is not working. The images are not displaying. How do i debug it?

Sebastian Morales commented on Mar 26, 2021

Pls try converting your image blob data to base64 via this function:

    //MyReport.php
    ...
    ->pipe(new \koolreport\core\Map(array(
        "{value}" => function($row) {
            $row["thumbnail_base64"] = base64_encode($row["thumbnail_url"]);
            return $row;
        }
    ...

Then in your report view, use the format function for column "thumbnail_base64" like instruction in the previous post:

        "thumbnail_base64" => array(
            "formatValue"=> "<img width='500px' height='400px' src='data:image/png;base64, @value' />"
        ),

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None