Thursday, December 1, 2011

Strip images from Joomla text and use independantly

in something like blog_item.php

$doc=new DOMDocument();
$doc->loadHTML($this->item->introtext.$this->item->fulltext);
$xml=simplexml_import_dom($doc); // just to make xpath more simple
$images=$xml->xpath('//img');
$src = end($images);
$src = $src['src'];
echo $src;

No comments: