What would be the best way to force jQuery to detect if an element in post-content class is an image and then display that image in-page. I have done this with BBCode many times, but want to make it easier for users. By just allowing them to paste the link and the system goes from there own.
$comments = $posts_row['post_content'];
$m = preg_match_all( "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/", $comment, $match);
if ($m) {
$links = $match[0];
foreach($links as $link) {
$extension = strtolower(trim(@end(explode(".",$link))));
switch($extension) {
case 'gif':
case 'png':
case 'jpg':
case 'jpeg':
$comment = str_replace($link, '<img src="'.$link.'">', $comment);
break;
default:
$comment = str_replace($link, '<a rel="nofollow" href="'.$link.'">'.$link.'</a>', $comment);
break;
}
}
}
Try this: