I'm using str_limit($data['last_post']['content'],800)
in blade for display first 800 characters from post. The problem is when user post video or image at the beginning of post. My question is: how to filter and remove iframe
, img
and display post first characters without this tags?
My recommendation would be to simply use $result = stripslashes($postDescription)
then use the below function to remove the iframe or image tags
function replacePostDesriptionUrls($postDesc = null) {
$regex = '/<iframe.*?>(.*?)<\/iframe>/';
return preg_replace_callback($regex,
function($m){
return escapeLink($m[0]);
}, $postDesc);
}
Do the same for any tags you want to remove from your post description.