Fixed allow_url_fopen with Mpdf

This commit is contained in:
Daniel Maya 2020-05-20 13:29:31 +02:00
parent e791d1b9b2
commit c8414c67ea
1 changed files with 15 additions and 0 deletions

View File

@ -133,6 +133,7 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
public function getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false, $interpolation = false)
{
global $config;
// mPDF 6
// firsttime i.e. whether to add to this->images - use false when calling iteratively
// Image Data passed directly as var:varname
@ -214,6 +215,20 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
$type = $this->guesser->guess($data);
}
}
if ((!$data || !$type) && !ini_get('allow_url_fopen') && preg_match('/data:image.*;base64/', $file)) {
$base_to_php = explode(',', $file);
$img_base64 = base64_decode($base_to_php[1]);
$filepath = $config['attachment_store']."/downloads/".uniqid().".jpg";
$result = file_put_contents($filepath, $img_base64);
if ($result !== false) {
$data = file_get_contents($filepath);
if ($data) {
$type = $this->guesser->guess($data);
}
unlink($filepath);
}
}
}
if (!$data) {