mirror of https://github.com/MISP/MISP
new: [internal] Attribute::isImage method
parent
063cbff491
commit
caa62220ff
|
@ -1727,6 +1727,17 @@ class Attribute extends AppModel
|
|||
return $this->saveAttachment($attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently, as image are considered files with JPG (JPEG), PNG or GIF extension.
|
||||
* @param array $attribute
|
||||
* @return bool
|
||||
*/
|
||||
public function isImage(array $attribute)
|
||||
{
|
||||
return $attribute['type'] === 'attachment' &&
|
||||
Validation::extension($attribute['value'], array('jpg', 'jpeg', 'png', 'gif'));
|
||||
}
|
||||
|
||||
public function getPictureData($attribute, $thumbnail=false, $width=200, $height=200)
|
||||
{
|
||||
$extension = explode('.', $attribute['Attribute']['value']);
|
||||
|
|
|
@ -5085,7 +5085,7 @@ class Event extends AppModel
|
|||
if (!$this->__fTool) {
|
||||
$this->__fTool = new FinancialTool();
|
||||
}
|
||||
if ($object['type'] == 'attachment' && preg_match('/.*\.(jpg|png|jpeg|gif)$/i', $object['value'])) {
|
||||
if ($this->Attribute->isImage($object)) {
|
||||
if (!empty($object['data'])) {
|
||||
$object['image'] = $object['data'];
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue