I save PNG's binary content in database.
I want display this PNG's on page without temporary save file on disk.
I think need generate img tag like <img src="data:image/png;base64,......
But I do not understand how it is better to implement it and what type of field to take as a basis.
            Image::make('Image')->displayUsing(function($item) {
                $mime_type = 'image/png';
                return 'data: ' . $mime_type . ';base64,' . base64_encode($item);
            }),
But Laravel Nova generated:
<img src="http://172.18.0.3/storage/data: image/png;base64,......" class="rounded-full w-8 h-8" style="object-fit: cover;">
Added unnecessary http://172.18.0.3/storage/and rounded class.
How to prevent it adding?
Work code for Laravel Nova 2.0.1:
Image::make('QRCode', 'qrcode')->thumbnail(function($value, $disk) {
    return 'data: image/png;base64,' . $value;
})->preview(function($value, $disk) {
    return 'data: image/png;base64,' . $value;
})->displayUsing(function($value) {
return  base64_encode($value);})
Also need remove rounded-full from field.thumbnailUrl?t("img",{staticClass:"rounded-full w-8 h-8", in file public\vendor\nova\app.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With