Fixed allow_url_fopen with Mpdf
This commit is contained in:
parent
e791d1b9b2
commit
c8414c67ea
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue