hello im trying to limit the text of every single news , my code works fine like this
<p> {{ substr(strip_tags($item->get_description()), 0, 500) }} </p>
but one thing i noticed, it removes all of the images of the news. is there any tricks to avoid that? thank you in advance
The second argument to strip_tags
lets you specify tags not to strip out. So, you can specify not to string out <img>
tags. You'll also need to change your blade output tags to {!! !!}
so that the html won't get escaped (assuming you're on Laravel 5).
<p> {!! substr(strip_tags($item->get_description(), '<img>'), 0, 500) !!} </p>