johnuk — 2012-08-20T03:43:40-04:00 — #1
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?
Kind regards and thanks,
markdidj — 2012-08-20T05:27:51-04:00 — #2
strip_tags is what you're looking for I think, This page should help....
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
You'll need that if you want to show some HTML but only whole tags.
johnuk — 2012-08-20T05:29:18-04:00 — #3
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
markdidj — 2012-08-20T05:30:57-04:00 — #4
Nice, and probably the fastest method processor-wise too
johnuk — 2012-08-20T05:31:43-04:00 — #5
Yeah its a neat solution, I really should have thought of it sooner however