new: [internal] Attribute::isImage method

pull/5302/head
Jakub Onderka 2019-10-12 09:34:49 +02:00
parent 063cbff491
commit caa62220ff
2 changed files with 12 additions and 1 deletions

View File

@ -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']);

View File

@ -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 {