[plugin:] The Inline Image Plugin

3rd party code for phpList

[plugin:] The Inline Image Plugin

Postby arnoldvl » 3:58pm, Tue 01 Apr, 2014

This plugin allows embed images in the content of messages as inline attachments. The total size together of all such attached images in a message is limited to 100 kB. See http://resources.phplist.com/plugins/inlineimage .
PL Nut
Posts: 18
Joined: 4:06pm, Mon 30 Dec, 2013
Location: Texas

Re: [plugin:] The Inline Image Plugin

Postby filed » 1:46am, Wed 17 Sep, 2014

Hello Arnold

I like your plugin. Thank you for tweaking it out. The plugin as such is working fine, although there is a problem with hosting providers where the PHP function file_get_contents() is disabled or not allowed to gather file data via HTTP.

In such a case, the temporary or cached files in /admin/plugins/inlineImagePlugin/images will be empty, and thus the attached inline images do not have any mime-data representing the image data (they are therefore also empty in phpList mail messages).

A possible solution would be to inlcude an additional private function within the class inlineImagePlugin to do socket requests at those two lines of code in your plugin, where the class is gathering the image file data.

You could use this function for example:
Code: Select all
   private function file_getContents($url) {
       $parsedurl = @parse_url($url);
      if (empty($parsedurl['host']))
         return null;
      $host = $parsedurl['host'];
      if (empty($parsedurl['path']))
         $documentpath = '/';
         $documentpath = $parsedurl['path'];
      if (!empty($parsedurl['query']))
         $documentpath .= $parsedurl['query'];
      if (!empty($parsedurl['port']))
         $port = $parsedurl['port'];
         $port = 80;
      $fp = fsockopen ($host, $port, $errno, $errstr, 30);
      if (!$fp)
         return null;
      fputs ($fp, "GET {$documentpath} HTTP/1.0\r\nHost: {$host}\r\n\r\n");
      do {
         $line = chop(fgets($fp));
      } while (!empty($line) and !feof($fp));
      $result = Array();
      while (!feof($fp)) {
         $result[] = fgets($fp);
      return $result;

Source: http://www.klamm.de/forum/f64/php-webse ... 16149.html

And replace "file_get_contents" with "$this->file_getContents" here
Code: Select all
            if (!$str = file_get_contents($src))

and here:
Code: Select all
          $fcontents = file_get_contents($src);

Kind regards from Switzerland
phpList newbie
Posts: 1
Joined: 11:32am, Fri 12 Jun, 2009

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 1 guest