Load background images from related mime parts.
authorJan Schneider <jan@horde.org>
Fri, 12 Nov 2010 12:38:45 +0000 (13:38 +0100)
committerJan Schneider <jan@horde.org>
Fri, 12 Nov 2010 13:57:21 +0000 (14:57 +0100)
imp/lib/Mime/Viewer/Html.php

index 9e0f250..43175aa 100644 (file)
@@ -295,7 +295,7 @@ class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         }
 
         if ($node instanceof DOMElement) {
-            $tag = strtolower($node->tagName);
+            $tag = Horde_String::lower($node->tagName);
 
             switch ($tag) {
             case 'a':
@@ -359,11 +359,25 @@ class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
 
             case 'body':
             case 'td':
-                if ($this->_imptmp['img'] &&
+                if ($this->_imptmp &&
                     $node->hasAttribute('background')) {
-                    $node->setAttribute('htmlimgblocked', $node->getAttribute('background'));
-                    $node->setAttribute('background', $this->_imptmp['blockimg']);
-                    $this->_imptmp['imgblock'] = true;
+                    $val = $node->getAttribute('background');
+
+                    /* Multipart/related. */
+                    if (isset($this->_imptmp['cid'][$val])) {
+                        $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array(
+                            'id' => $this->_imptmp['cid'][$val],
+                            'imp_img_view' => 'data'
+                        )));
+                        $node->setAttribute('background', $val);
+                    }
+
+                    /* Block images.*/
+                    if ($this->_imptmp['img']) {
+                        $node->setAttribute('htmlimgblocked', $val);
+                        $node->setAttribute('background', $this->_imptmp['blockimg']);
+                        $this->_imptmp['imgblock'] = true;
+                    }
                 }
                 break;
             }