You are here

function mimemail_extract_files in Mime Mail 5

Same name and namespace in other branches
  1. 6 mimemail.inc \mimemail_extract_files()
  2. 7 mimemail.inc \mimemail_extract_files()

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 mimemail_extract_files()
mimemail_html_body in ./mimemail.inc
Generate a multipart message body with a text alternative for some html text

File

./mimemail.inc, line 87

Code

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