While i was woking with Joomla Easy Blog ran into a problem where i have to get image/image link from the DB result in which all of the blog content was mixed.I used below method for that after a long session with regx and all.Happy coding. And for sure regx never helped me
$html = $row->text;
$base_url = JURI::root();
// $dom->load('test.html'); // if in a file
$dom->loadHTML($html); // if in a string
for ($i=0;
$i<$dom->getElementsByTagName('img')->length;
$i++) {
$sam = $dom->getElementsByTagName('img')->item($i)->getAttribute('src');
echo $base_url$sam ;//use this for image source
}
?>
0 comments:
Post a Comment