i am adding a column in datatable for image like this :
->addColumn('product_brand_logo', function ($product_brand) {
return '<img src="{{ URL::to('upload/image')'.$img->image.'" border="0" width="40" class="img-rounded" align="center" />';
its not working the output in inspect
| {{ URL::to('upload/image')imagename.png}}|
using laravel 5.3, yajra datatable 6.0
You didn't close
{{
insrc
attribute, try this :If you are use datatable 7.0
Then you can use rawColumns
To Display image in DataTable, we need to use render function on the column to display images. You can define your own render function. In our case, we want to render an image, something like following,
overall look like this -
Hope this helps
I had almost the same problem... and it was solved with the following code in my
UserController
.In my example, I don´t save the image in the DB, only the name of the image to access with the image name stored in my project...
Nice.. it works
->addColumn('image', function ($user) { $url=asset("uploads/image/$user->avatar"); return '<img src='.$url.' border="0" width="40" class="img-rounded" align="center" />'; });