public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null) { if (!is_array($data) && !is_string($data)) { return parent::processRawFieldData($data, $status, $message, $simulate, $entry_id); } if (is_array($data) && isset($data['name']) && $this->get('unique') == 'yes') { $data['name'] = $this->getUniqueFilename($data['name']); } $max_width = $this->get('max_width'); $max_height = $this->get('max_height'); // file already exists in Symphony if (is_string($data)) { // 1. process Upload $result = parent::processRawFieldData($data, $status, $message, $simulate, $entry_id); // Find Mime if it was not submitted if ($result['mimetype'] === 'application/octet-stream') { if (function_exists('finfo_file')) { $result['mimetype'] = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $data['name']); } } // 2. resize if ($this->isResizeActive() && $result['mimetype'] !== 'application/octet-stream' && !static::isSvg($result['mimetype'])) { if (!empty($max_width) && $max_width > 0 || !empty($max_height) && $max_height > 0) { if (is_file($file = WORKSPACE . $result['file'])) { $dimensions = $this->figureDimensions(static::getMetaInfo($file, $result['mimetype'])); if ($dimensions['proceed']) { if (self::resize($file, $dimensions['width'], $dimensions['height'], $result['mimetype'])) { $result['size'] = filesize($file); $result['meta'] = serialize(static::getMetaInfo($file, $result['mimetype'])); } } } } } } else { if (is_array($data)) { // 1. resize if ($this->isResizeActive() && !static::isSvg($result['mimetype'])) { if (!empty($max_width) && $max_width > 0 || !empty($max_height) && $max_height > 0) { if (is_file($file = $data['tmp_name'])) { $dimensions = $this->figureDimensions(static::getMetaInfo($file, $data['type'])); if ($dimensions['proceed']) { if (self::resize($file, $dimensions['width'], $dimensions['height'], $data['type'])) { $data['size'] = filesize($file); } } } } } // 2. process Upload $result = parent::processRawFieldData($data, $status, $message, $simulate, $entry_id); } } return $result; }
public function processRawFieldData($data, &$status, $simulate = false, $entry_id = NULL) { if (!is_array($data) || empty($data)) { return parent::processRawFieldData($data, $status, $simulate, $entry_id, $language_code); } $result = array(); $field_data = $data; foreach (FLang::instance()->ld()->languageCodes() as $language_code) { $data = $this->_getData($field_data[$language_code]); if ($this->get('unique') == 'yes' && is_array($data) && isset($data['name'])) { $data['name'] = $this->_getUniqueFilename($data['name'], $language_code); } $this->_fakeDefaultFile($language_code, $entry_id); $file_result = parent::processRawFieldData($data, $status, $simulate, $entry_id, $language_code); foreach ($file_result as $key => $value) { $result[$key . '-' . $language_code] = $value; } } return (array) $result; }