mirror of https://github.com/MISP/MISP
parent
9f3e6ce20e
commit
b64e0bc61d
|
@ -8,6 +8,7 @@ class ImageHelper extends AppHelper
|
||||||
private $imageCache = [];
|
private $imageCache = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Converts image file to data format
|
||||||
* @param string $imagePath Path to file
|
* @param string $imagePath Path to file
|
||||||
* @return string
|
* @return string
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -18,13 +19,13 @@ class ImageHelper extends AppHelper
|
||||||
return $this->imageCache[$imagePath];
|
return $this->imageCache[$imagePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = pathinfo($imagePath, PATHINFO_EXTENSION);
|
$ext = strtolower(pathinfo($imagePath, PATHINFO_EXTENSION));
|
||||||
if ($ext === 'svg') {
|
if ($ext === 'svg') {
|
||||||
$mime = 'image/svg+xml';
|
$mime = 'image/svg+xml';
|
||||||
} else if ($ext === 'png') {
|
} else if ($ext === 'png') {
|
||||||
$mime = 'image/png';
|
$mime = 'image/png';
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException("Only SVG and PNG images are supported");
|
throw new InvalidArgumentException("Only SVG and PNG images are supported, '$ext' file provided.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue