2

I am facing a problem displaying image in data table. The below code is displaying the whole html(HTML is not getting rendered) in side the column. It used to work with laravel 5.3 and below. How to get it working with laravel 5.4. Thanks.

        $data = Member::query()
        ->get();
        return Datatables::of($data)
        ->addColumn('picture', function ($data) {
            return '<img src=" '.$data->picture.' "/>';
        })
        ->make(true);

2 Answers 2

9

Okay I found the solution you just need to add ->rawColumns() before ->make(true)

->rawColumns(['picture', 'confirmed'])

while returning. Cheers!!

Sign up to request clarification or add additional context in comments.

1 Comment

may I ask you to have a look at a yajra dataTable related question here : stackoverflow.com/questions/53208578/… ?
1

you have to define the full src of image in img tag

Like this
<img style="width: 140px;" src="/images/your-folder-name/'.$data->pictur.'">

3 Comments

yea, I know that but it is displaying the raw html. If the path is incorrect it should show the broken image. the image tag u posted is totally wrong. Sorry but this is not the solution to my problem
what you exactly want ?
HTML is not getting rendered in laravel 5.4. However in 5.3 and below it used to work like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.