@$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
$imgs= $dom->getElementsByTagName('img');
- $test = array();
+ $urls = array();
foreach ($imgs as $i=>$img) {
$url = $img->getAttribute('src');
if ($me == 'no') {
continue;
}
- $test[] = $url;
+
+ if(!array_key_exists($url, $urls)){
+ $conv = $this->fetchImage($url);
+ $urls[$url] = $conv;
+ $this->images[$conv['contentid']] = $conv;
+ } else {
+ $conv = $urls[$url];
+ }
+
+ $img->setAttribute('src', 'cid:' . $conv['contentid']);
}
- print_R($test);exit;
-
+ /*
foreach ($imgs as $i=>$img) {
$url = $img->getAttribute('src');
if (preg_match('#^cid:#', $url)) {
$this->images[$conv['contentid']] = $conv;
$img->setAttribute('src', 'cid:' . $conv['contentid']);
-
-
}
+ *
+ */
+
return $dom->saveHTML();