$htmlbody = $this->htmlbodyCssEmbed($htmlbody);
}
- if ($this->css_inline) {
- $htmlbody = $this->htmlbodyinlineCss($htmlbody);
+ if ($this->css_inline && strlen($this->css_inline)) {
+ $htmlbody = $this->htmlbodyInlineCss($htmlbody);
}
}
}
-
+ function htmlbodyInlineCss($html)
+ {
+ $dom = new DOMDocument();
+
+ @$dom->loadHTML('<?xml encoding="UTF-8">' .$html);
+
+ $html = $dom->getElementsByTagName('html');
+
+ $head = $dom->getElementsByTagName('head');
+
+ if(!$head->length){
+ $head = $dom->createElement('head');
+ $html->item(0)->appendChild($head);
+ }
+
+ $s = $dom->createElement('style');
+ $e = $dom->createTextNode($this->css_inline);
+ $s->appendChild($e);
+ $body->item(0)->appendChild($s);
+
+ return $dom->saveHTML();
+ }
function fetchImage($url)
{