Break String *after* IMG or EMBED tags?

Hello everyone,

 I created a mini "blog feed" for the front page of my clients website. I want to be able to truncate each of the posts and add a "read more" link the end. Easy enough job, accept each blog post may or may not contain 'IMG' (auto resized) and 'EMBED' (youtube vids) tags  and I want to ensure the string is NOT broken on those tags or it will display an empty link.

So my question is, what would be the best way to tackle the problem? :slight_smile:

Kind regards and thanks,

strip_tags is what you’re looking for I think, This page should help…
http://php.net/manual/en/function.strip-tags.php

That would remove ALL HTML from the preview.

There is a little bit of regular expression further down the page. Look in to that too. Powerful stuff :slight_smile:
You’ll need that if you want to show some HTML but only whole tags.

hey! funny enough I went with strip_tags in the end. Then I opted to prepend a video or image onto the string with the title "attached media! - seems to work nice :slight_smile:

Nice, and probably the fastest method processor-wise too :slight_smile:

Yeah its a neat solution, I really should have thought of it sooner however :wink: