str_limit truncates at the wrong point

Posted 6 months ago by Zaverius

Hello! First of all, I'm still learning Laravel so my apologies if my question may seem obvious.

I'm making a content manager for a project we're working on school, and I'm trying to limit the content of the news in the view. This content is saved as an HTML in the database. If str_limit truncates exactly on an image, it won't display the three dots and the rest of the website (particularly the footer) becomes visually buggy.

{!! str_limit($news->content, 550) !!}

What am I doing wrong? How can I truncate counting the HTML tags too?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.