|
@@ -309,37 +309,44 @@ class View
|
|
|
|
|
|
if ($id > 0) {
|
|
|
$host = Dever::config('host')->uploadRes;
|
|
|
- $root = Dever::data() . 'upload/';
|
|
|
- $source = Dever::pic($source);
|
|
|
- $dest = str_replace(array('{uploadRes}', $host), $root, $file);
|
|
|
- $path = str_replace(array('{uploadRes}', $host), '', $file);
|
|
|
- if (strstr($source, $host)) {
|
|
|
-
|
|
|
- $source = $root . str_replace($host, '', $source);
|
|
|
+ $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];
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (!is_file($source)) {
|
|
|
- $source = $array[0];
|
|
|
+ if ($type == 'wp') {
|
|
|
+ $temp = explode('.', $dest);
|
|
|
+ $dest = $temp[0] . '.webp';
|
|
|
+ $file = str_replace($root, $host, $dest);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($type == 'wp') {
|
|
|
- $temp = explode('.', $dest);
|
|
|
- $dest = $temp[0] . '.webp';
|
|
|
- $file = str_replace($root, $host, $dest);
|
|
|
+ if (is_file($dest)) {
|
|
|
+ $file = $dest;
|
|
|
+ $handle = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (is_file($dest)) {
|
|
|
- $file = $dest;
|
|
|
- } else {
|
|
|
- if (!strstr($dest, 'http://')) {
|
|
|
- $temp = explode('/', $path);
|
|
|
- $key = $temp[0];
|
|
|
- $image['file'] = false;
|
|
|
- $image['key'] = $key;
|
|
|
- $handle = new Handle($image);
|
|
|
- $method = 'handle_' . $type;
|
|
|
- $file = $handle->$method($id, $source, $dest, $path);
|
|
|
- }
|
|
|
+ if ($handle) {
|
|
|
+ $temp = explode('/', $path);
|
|
|
+ $key = $temp[0];
|
|
|
+ $image['file'] = false;
|
|
|
+ $image['key'] = $key;
|
|
|
+ $handle = new Handle($image);
|
|
|
+ $method = 'handle_' . $type;
|
|
|
+ $file = $handle->$method($id, $source, $dest, $path);
|
|
|
}
|
|
|
}
|
|
|
|