[imp] Inline Images (corrected)

Michael Wright michael@abditory.com
Fri, 17 May 2002 13:19:55 -0400


ALCON, 

Over the year or two that I have used IMP, I have seen several requests for 
inline images on this listserv. I haven't found code on this listserv to solve 
this request, though I admit I may not be looking hard enough. If this 
functionality is already out there, please accept my apology and delete this 
message with all due speed. :-) 

That being said, I created a little hack to work inline images into html mail. 
The bottom line is that images cannot _truly_ be viewed inline, but you can 
view them with an <img..> tag in the html output of imp. Currently, images are 
added to the attachment list and are available for viewing in a separate 
window. I simply took the code for this process (spanning several files) and 
compiled it into the message.php file. The modification necessary is below: 

/horde/imp/message.php: 

To the foreach($displayParts as $ref => $mime) loop that goes through each mime 
part and decides whether to inline it or add it to the attachment list, add the 
following code - 

<code snippet> 

    # This code will tack any images onto the end of the body of the message. 
    if(isset($mime->TYPE)) 
      { 
      if($mime->TYPE == 'image') 
        { 
        $imagepath = 'view.php?index=' . Horde::getFormData
('index') . '&array_index=' . Horde::getFormData('array_index') . '&id=' . 
$mime->imap_id . '&actionID=' . 'VIEW_ATTACH' . '&mime=' . 
SessionCache::putObject($mime);

        $msg .= '<br><br><img src="' . $imagepath . '"><br><br>'; 
        } 
      } 

</code snippet> 

Bear in mind that this is a security risk and any code of mine that you use is 
strictly "as-is" and no guarantees are packaged with it. 

A screenshot of this working can be found here: 

http://www.abditory.com/modules.php? 
set_albumName=Screenshots&id=aab&op=modload&name=Gallery&file=index&include=view
_photo.php 



-=-=-=-=-=-=-=-=-=-=-=-=
http://www.abditory.com

For when you just can't
get enough of me!
-=-=-=-=-=-=-=-=-=-=-=-=