Commit 9ac61d37 authored by jcnventura's avatar jcnventura

Add support for private file images in PDFs.

parent 83acf5b7
......@@ -129,6 +129,7 @@ function _print_pdf_file_access_images($html) {
$print_pdf_images_via_file = variable_get('print_pdf_images_via_file', PRINT_PDF_IMAGES_VIA_FILE_DEFAULT);
// TODO: This needs to be rewritten from scratch for Drupal 7
$lang = '';
/*
switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
......@@ -139,19 +140,17 @@ function _print_pdf_file_access_images($html) {
$lang = '';
break;
}
*/
// Always convert private to local paths
$file_downloads = variable_get('file_default_scheme', 'public');
if ($file_downloads == 'private') {
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files/([^>]*?>)!is";
$replacement = '$1file://' . realpath(file_directory_path()) . '/$2';
$html = preg_replace($pattern, $replacement, $html);
}
elseif ($print_pdf_images_via_file) {
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?system/files/([^>]*?>)!is";
$replacement = '$1file://' . realpath(variable_get('file_private_path', '')) . '/$2';
$html = preg_replace($pattern, $replacement, $html);
if ($print_pdf_images_via_file) {
$pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?)${base_url}/(?:(?:index.php)?\?q=)?(?:${lang}/)?([^>]*?>)!is";
$replacement = '$1file://' . dirname($_SERVER['SCRIPT_FILENAME']) . '/$2';
$html = preg_replace($pattern, $replacement, $html);
}
*/
return $html;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment