[英]How to use base64 string from database to display an image
How can I use base64 string from database to display an image? 如何使用数据库中的base64字符串显示图像? I can't see any function to convert this by using jQuery DataTables. 我看不到使用jQuery DataTables进行转换的任何函数。
oTableImage = $('#tbl_image').DataTable({
"processing": true,
"destroy": true,
"paging":false,
"bFilter": false,
// "scrollY": "200px",
"ajax":{
"type":"POST",
dataType: "json",
"url":"{{ URL::to('ajax/per-seller-image') }}",
"data":function(d){
d.rtd_id =rtd;
}
},
"columns":[
{data: 'start_image', name: 'start_image'}
]
});
});
You can show a base64 encoded image in HTML like this: 您可以使用HTML显示以base64编码的图像,如下所示:
<img src="data:image/png;base64,xxxxxxxxxxBASE64_HASHxxxxxxxx===">
And then render the <img>
tag in DataTable: 然后在DataTable中呈现<img>
标签:
"columns": [
{
"render": function (data, type, row) {
return '<img src="data:image/png;base64,' + row.start_image + '">';
}
}
],
Base64 data will be automatically rendered by browser itself. Base64数据将由浏览器本身自动呈现。 You don't have to convert. 您不必转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.