|
@@ -298,6 +298,18 @@ class View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ # 获取云端配置
|
|
|
+ public function getYun($key)
|
|
|
+ {
|
|
|
+ $key = Dever::input('key', $key);
|
|
|
+ $config = Dever::db('upload/upload')->one($key);
|
|
|
+ if ($config && $key && $config['save_type'] >= 2 && $config['yun'] > 0) {
|
|
|
+ $yun = Dever::db('upload/yun')->one($config['yun']);
|
|
|
+ return $yun['host'];
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
# 根据配置生成缩略图 暂时支持缩略图
|
|
|
public function get($file = '')
|
|
|
{
|
|
@@ -307,46 +319,51 @@ class View
|
|
|
$type = $array[1];
|
|
|
$id = $array[2];
|
|
|
|
|
|
- if ($id > 0) {
|
|
|
- $host = Dever::config('host')->uploadRes;
|
|
|
- $dest = $file;
|
|
|
- $path = '';
|
|
|
- $handle = true;
|
|
|
- if (strstr($file, '{uploadRes}') || strstr($file, $host)) {
|
|
|
- # 本地的
|
|
|
- $root = Dever::data() . 'upload/';
|
|
|
- $source = Dever::pic($source);
|
|
|
- $dest = str_replace(array('{uploadRes}', $host), $root, $file);
|
|
|
- $path = str_replace($root, '', $dest);
|
|
|
- if (strstr($source, $host)) {
|
|
|
-
|
|
|
- $source = $root . str_replace($host, '', $source);
|
|
|
-
|
|
|
- if (!is_file($source)) {
|
|
|
- $source = $array[0];
|
|
|
- }
|
|
|
- }
|
|
|
+ $host = Dever::config('host')->uploadRes;
|
|
|
+ $dest = $file;
|
|
|
+ $path = '';
|
|
|
+ $handle = true;
|
|
|
+ $local = false;
|
|
|
+ if (strstr($file, '{uploadRes}') || strstr($file, $host)) {
|
|
|
+ # 本地的
|
|
|
+ $local = true;
|
|
|
+ $root = Dever::data() . 'upload/';
|
|
|
+ $source = Dever::pic($source);
|
|
|
+ $dest = str_replace(array('{uploadRes}', $host), $root, $file);
|
|
|
+ $path = str_replace($root, '', $dest);
|
|
|
+ if (strstr($source, $host)) {
|
|
|
+
|
|
|
+ $source = $root . str_replace($host, '', $source);
|
|
|
|
|
|
- if ($type == 'wp') {
|
|
|
- $temp = explode('.', $dest);
|
|
|
- $dest = $temp[0] . '.webp';
|
|
|
- $file = str_replace($root, $host, $dest);
|
|
|
+ if (!is_file($source)) {
|
|
|
+ $source = $array[0];
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (is_file($dest)) {
|
|
|
- $file = $dest;
|
|
|
- $handle = false;
|
|
|
- }
|
|
|
+ if ($type == 'wp') {
|
|
|
+ $temp = explode('.', $dest);
|
|
|
+ $dest = $temp[0] . '.webp';
|
|
|
+ $file = str_replace($root, $host, $dest);
|
|
|
}
|
|
|
|
|
|
- if ($handle) {
|
|
|
- $temp = explode('/', $path);
|
|
|
- $key = $temp[0];
|
|
|
- $image['file'] = false;
|
|
|
- $image['key'] = $key;
|
|
|
- $handle = new Handle($image);
|
|
|
+ if (is_file($dest)) {
|
|
|
+ $file = $dest;
|
|
|
+ $handle = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($handle) {
|
|
|
+ $temp = explode('/', $path);
|
|
|
+ $key = $temp[0];
|
|
|
+ $image['file'] = false;
|
|
|
+ $image['key'] = $key;
|
|
|
+ $handle = new Handle($image);
|
|
|
+ if ($type) {
|
|
|
$method = 'handle_' . $type;
|
|
|
$file = $handle->$method($id, $source, $dest, $path);
|
|
|
+ } elseif (!$local) {
|
|
|
+ $yun = $handle->yun->getData();
|
|
|
+ $file = $yun['host'] . $source;
|
|
|
}
|
|
|
}
|
|
|
|