function mimemail_extract_files in Mime Mail 6
Same name and namespace in other branches
- 5 mimemail.inc \mimemail_extract_files()
- 7 mimemail.inc \mimemail_extract_files()
Helper function to extracts links to local images from HTML documents.
Parameters
$html: A string containing the HTML document.
$name: A string containing the document's name.
Return value
An array of arrays containing the extraced files.
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 97 - Common mail functions for sending e-mail. Originally written by Gerhard.
Code
function mimemail_extract_files($html) {
$pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |[\\s]src=[\'"]?)([^\'>"]+)([\'"]?)/mis';
$content = preg_replace_callback($pattern, '_mimemail_replace_files', $html);
$encoding = '8Bit';
$body = explode("\n", $content);
foreach ($body as $line) {
if (strlen($line) > 998) {
$encoding = 'base64';
break;
}
}
if ($encoding == 'base64') {
$content = rtrim(chunk_split(base64_encode($content)));
}
$document = array(
array(
'Content-Type' => "text/html; charset=utf-8",
'Content-Transfer-Encoding' => $encoding,
'content' => $content,
),
);
$files = _mimemail_file();
return array_merge($document, $files);
}