You are here

function Messaging_HTML_MailSystem::mimemail_extract_files in Messaging 7

Extracts links to local images from html documents.

Parameters

$html html text:

$name document name:

Return value

an array of arrays array(array( 'name' => document name 'content' => html text, local image urls replaced by Content-IDs, 'Content-Type' => 'text/html; charset=utf-8') array( 'name' => file name, 'file' => reference to local file, 'Content-ID' => generated Content-ID, 'Content-Type' => derived using mime_content_type if available, educated guess otherwise ) )

1 call to Messaging_HTML_MailSystem::mimemail_extract_files()
Messaging_HTML_MailSystem::mimemail_html_body in messaging_htmlmail/messaging_htmlmail.inc
Generate a multipart message body with a text alternative for some html text

File

messaging_htmlmail/messaging_htmlmail.inc, line 369
Drupal Messaging Framework - Send_Method class file

Class

Messaging_HTML_MailSystem
Sendgrid mail system

Code

function mimemail_extract_files($html) {
  $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |[\\s]src=[\'"]?)([^\'>"]+)([\'"]?)/mis';
  $html = preg_replace_callback($pattern, '_messaging_htmlmail_replace_files', $html);
  $document = array(
    array(
      'Content-Type' => "text/html; charset=utf-8",
      'Content-Transfer-Encoding' => '8bit',
      'content' => $html,
    ),
  );
  $files = _messaging_htmlmail_file();
  return array_merge($document, $files);
}