public function getJsField($content) { parent::getJsField($content); $this->_js_field['type'] = 'image'; $f = $this->_js_field; if (isset($f['value']) && isset($f['value']['path']) && $f['value']['path']) { $thumb = new \Floxim\Floxim\System\Thumb($f['value']['path']); $info = $thumb->getInfo(); if ($info && isset($info['width']) && isset($info['height'])) { $this->_js_field['value'] = array_merge($f['value'], array('width' => $info['width'], 'height' => $info['height'])); } } return $this->_js_field; }
public function saveFile($file, $dir = '', $name = null) { // normal $_FILES if (is_array($file)) { $filename = $file['name']; $put_file = $this->getPutFilename($dir, $filename); $full_path = fx::path('@files/' . $dir . '/' . $put_file); $this->mkdir(fx::path('@files/' . $dir)); $res = move_uploaded_file($file['tmp_name'], $full_path); if (!$res) { return; } } else { if (is_string($file)) { $full_path = $this->saveRemoteFile($file, $dir, $name); if (!$full_path) { return; } } } $result = array('filename' => fx::path()->fileName($full_path), 'fullpath' => $full_path, 'size' => $this->readableSize(filesize($full_path))); // default image resizer $resize_config = fx::config('image.default_resize'); if ($this->isImage($full_path)) { $thumb = new \Floxim\Floxim\System\Thumb($full_path, $resize_config); $img_info = $thumb->getInfo(); $result['is_image'] = true; if ($img_info && isset($img_info['width']) && isset($img_info['height'])) { $result['width'] = $img_info['width']; $result['height'] = $img_info['height']; } if ($resize_config) { $thumb->process($full_path); } } $http_path = fx::path()->http($full_path); $result['path'] = $http_path; return $result; }